I have a combo box in an Access 97 form of people's names which is populated by a stored query derived from a table called 'Caller'. The people, in question, phone into the user. Sometime these people don't give their name and my user wanted a button to choose the 'Not Given' name from the list.
The first time the form is opened the following code works fine and 'Not Given' is displayed. However, when the first instance is saved and the screen clears to record the next caller, the 'Not Given' button does not work - no entry from the combo box is selected. Presumably, the form wants to be refreshed or even requeried but as there are 2 or 3 mandatory fields, Access doesn't like this. Any ideas, please?
Private Sub cmdNotGiven_Click()
Dim varname As Variant
varname = DLookup("[ID]", "Caller", _
"[LastName] = 'Given' And [FirstName] = 'Not'"
Me!Combo56.DefaultValue = varname
Me.Combo56.Requery
End sub
Steve House
shouse@icaew.co.uk
The first time the form is opened the following code works fine and 'Not Given' is displayed. However, when the first instance is saved and the screen clears to record the next caller, the 'Not Given' button does not work - no entry from the combo box is selected. Presumably, the form wants to be refreshed or even requeried but as there are 2 or 3 mandatory fields, Access doesn't like this. Any ideas, please?
Private Sub cmdNotGiven_Click()
Dim varname As Variant
varname = DLookup("[ID]", "Caller", _
"[LastName] = 'Given' And [FirstName] = 'Not'"
Me!Combo56.DefaultValue = varname
Me.Combo56.Requery
End sub
Steve House
shouse@icaew.co.uk