Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
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:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old October 10th, 2003, 03: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, 07: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: 6
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!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway