set value of several controls based on particular value of another control on subform

ehdoh

Registered User.
Local time
Yesterday, 23:37
Joined
Jun 24, 2003
Messages
58
Forgive me if this has been discussed before...my quick search turned up nothing.

What I would like to do is have the value of several controls be filled in based on the value of another (let's say gateway) control. I have done this before, but only when the value of the gateway control did not matter. In this case, I only want the value of the multiple controls that need filling in to be identical to the gateway control under particular circumstances.

Thus far, here is the code I have written on the gateway control for another purpose:


Private Sub Combo20_AfterUpdate()
If Me.Combo20 = 1 Then
DoCmd.GoToControl "combo24"
Else
DoCmd.GoToControl "combo57"
'if yes to any alzheimers in family answer questions about specific family members,
'else jump to next category of questions
End If

End Sub


Can I also add some code to the AfterUpdate event to specify that iff Me.Combo20= 2 then several other combo responses should equal 2?? I tried accomplishing this in a macro a couple weeks back but somehow that managed to lock up my form. I am hoping to accomplish this in code only, and be able to keep the existing code pasted above (or at least a modified version that accomplishes the same task).

Your assistance will be appreciated!
E. :)
 
You could try a Select Case Statement

Private Sub Combo20_AfterUpdate()
...Select Case Me.Combo20
......Case 1
.........DoCmd.GoToControl "combo24"
.........Me.Combo1.Enabled = False
.........Me.txtTwo.Enabled = False
......Case 2
.........Me.Combo1 = 2
.........Me.txtTwo = 2
.........Me.Combo57.SetFocus
......Case 3
.........'Do a bunch of different things
......Case Else
.........'Do none of the above
...End Select
End Sub

???
 
EXCELLENT!!! This was exactly what I was looking for but had not encountered it until you brought it to my attention. I have reprogrammed and the Select Case command works very well. Thank you, thank you!!! :D
 

Users who are viewing this thread

Back
Top Bottom