How do I get a form to remember the last value?

R

Robyn

I have created a form to look up client records in two unrelated tables using
LName and FName fields. If a client is in both tables or only in the second
table, the records pop up after clicking the OK button twice. However, If the
client is only in the first table, after clicking OK twice, the name
disappears from the two unbound text boxes, and I have to type in the last
and first name again, click OK (names disappear again) type in the names a
second time and click OK in order to obtain the report. Is there a way to
make this form work with only one click and no extra typing?
 
B

Barry Gilbert

I think we need more information. Is the Ok button generated by your
code? If not, what does the message say? How are you doing the lookups
in the tables? More details, please.
 
R

Robyn

The tables are linked to the form with LName and FName fields criteria
expressions.

Here is the code related to the OK button:

Private Sub OK_Click()

If IsNull([LName]) Or IsNull([FName]) Then
MsgBox "You must enter both Last and First Names."
DoCmd.GoToControl "LName"
Else
Me.Visible = False
End If
End Sub
 
B

Barry Gilbert

Sorry. I'm still don't get it. Your code indicates that if the user
entered both names, the form is made invisible. How does this button
have anything to do with values in a table?
 

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