On Change - Revised

G

Gary Nelson

In Access2000, I have a field on a sub-form that allows the user to change a
date and
another field on the main form that has a drop down of reasons the date is
going to be
changed. Once the date is changed, I would like the focus to be changed to
the "reason" drop down field, and not allow the user to exit the form until
a reason is selected. Can anyone offer code choices?

Thanks in adavnce for the help.
 
W

Wayne Morgan

In the AfterUpdate event of the textbox that has the date, try something like

If IsDate(Me.txtDate) Then
Me.Parent.cboCombobox.SetFocus
DateChanged = True
Else
Msgbox "Not a valid date. Try again.", vbokonly+vbExclamation, "Invalid Date"
Me.txtDate.SetFocus
End If

When you set the focus to the control on the parent form, the record will be saved on the
subform. DateChanged could be a global variable that you would set to true when the date
is changed and set to false when the reason is selected. In the main form's UnLoad event,
you could check the value of this variable and Cancel the unload if the variable is True.
 

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