if change selection then go to specific tex box

D

Dennis Wolf

Hi,
I have a drop down box which gives me two options- "admitted" and
"discharged". Default is "admitted"- if the user changes the option to
"discharged" I want the user to be forced to enter the discharge date (which
is a date picker) before being able to carry on.
Thanks
Dennis
 
J

John W. Vinson

Hi,
I have a drop down box which gives me two options- "admitted" and
"discharged". Default is "admitted"- if the user changes the option to
"discharged" I want the user to be forced to enter the discharge date (which
is a date picker) before being able to carry on.
Thanks
Dennis

You can use the Form's BeforeUpdate event to check the state of the combo:

Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim iAns As Integer
If Me!comboboxname = "Discharged" Then
If IsNull(Me!datepickername) Then
IAns = MsgBox("Enter discharge date or click Cancel", vbOKCancel)
Cancel = True
If iAns = vbCancel Then ' wipe the form if the user selects Cancel
Me.Undo
Else
Me.datepickername.SetFocus
End If
End If
End If
End Sub

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top