|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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, |
|
#2
|
|||
|
|||
|
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 |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > compare main form controls to subform controls |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|