Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 10th, 2003, 04:23 PM
rythmeen7 rythmeen7 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 1 rythmeen7 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
compare main form controls to subform controls

Hello,

I have a form frmMissyFact and within this form I have a subform frmMissyFactbackup. the sub form is an exact copy of the mainform. The data source is different. What I am trying to do is compare the controls value on the mainform to the controls value on the sub form and if they don't match set the back color to Yellow. Basically the user want to know what has changed from the week before. I am trying to use a for loop. this is the code I have.

Private Sub Form_Current2()

Dim ctl As Control
Dim frmMain As Form
Dim frmSub As Form

Set frmMain = Me
Set frmSub = Me.frmMissyFactbackup.Form

For Each ctl In frmMain.Controls
If ctl.Value = frmSub.ctl(ctl.Name).Value Then
'set to normal color
Else
ctl.BackColor = vbYellow
End If
Next ctl

I keep getting a runtime error. Application defined or object defined error.

Does anybody have any Ideas on how i can make this work. I know I can write an if statement for each control but if theres a loop I can use it would be better.
Thanks,

Reply With Quote
  #2  
Old October 15th, 2003, 08:02 AM
m_lazor m_lazor is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Luxembourg
Posts: 156 m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level)m_lazor User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Well, since there is no real support for sub forms in VB (as opposed to Access) I believe you are talking about a comparison of two instances of the same form. If this is true we can assume that the control names are identical and their number, as well.
Hence:
Form1(ctl.name).name = Form2(ctl.name).name
or for values
Form1(ctl.name).text = Form2(ctl.name).text


For Each ctl In frmMain.Controls
'*** I assume these are text boxes ***
If ctl.Text = frmSub(ctl.Name).Text Then
'set to normal color if has been set to Yellow before
ctl.BackColor = vbWhite
Else
ctl.BackColor = vbYellow
End If
Next ctl

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > compare main form controls to subform controls


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek