Textbox problems

bbulla

I'd rather be golfing
Local time
Today, 16:49
Joined
Feb 11, 2005
Messages
101
Hello,

So I have a checkbox in a subform that if a user checks then the address info from the main form should be transferred to fields the subform. Here is my code:

Private Sub Check5_Click()

If Check5.Value = -1 Then
add.Text = Me.Parent.add.Text '*
city.Text = Me.Parent.city.Text
prov.Text = Me.Parent.prov.Text
postal.Text = Me.Parent.postal.Text
End If

If Check5.Value = 0 Then
If add.Value <> "" Then
If MsgBox("Are you sure you want to change this info?", vbInformation + vbYesNo, "Confirm")= vbYes Then
add.Text = "" '*
city.Text = ""
prov.Text = ""
postal.Text = ""
End If
End If
End If 'added this end if to stop the Block without End If error

End Sub


First, any idea why I need that 'End If' comment??? The code won't run without it.

Second, I keep getting a "Can't reference a property or method unless the control has the focus" on the lines commented with a *. Why is that??? I'm certain I've done this before in VB but haven't run into these sorts of errors before.

Am I referenceing something improperly??

Thanks

Brian
 
Ahhh....that helped. I found another post with the same problem. This code worked.

Private Sub Check5_Click()

If Check5.Value = -1 Then
add = "It works"
Else
add = ""
End If

End Sub


VBA blows!!! Any idea why I don't need to reference add.text? Apparantly an MS Access text box is different than a VB text box?!?

Thanks for your help!
 
Textbox problem: reply

Hello.
You have 3 If statements and you need 3 End If statements.
 

Users who are viewing this thread

Back
Top Bottom