verify matching records before opening form

  • Thread starter vircalendar via AccessMonster.com
  • Start date
V

vircalendar via AccessMonster.com

I've searched for an answer to this question without luck, tho it seems
pretty simple.

I have a patient scheduling form (caled "switchboard") that includes a button
for record search. If that button is clicked, it opens another form, called
MRNfinder, that asks for the patient's medical record number. If that number
is found, I want to open another form called "history" that shows the
patient's data. If the number is not not found, I don't want the history form
to open at all, but rather to have a simple message that no matching record
was found. Like I said - it seems pretty easy. Still, I'm stuck.
 
J

John Vinson

If the number is not not found, I don't want the history form
to open at all, but rather to have a simple message that no matching record
was found. Like I said - it seems pretty easy. Still, I'm stuck.

The simplest way would be to either open a Recordset (if you're
defining a query to select the history records) or use DLookUp to look
up a record in the history table; if no record is found issue an error
message. E.g.

If IsNull(DLookUp("[MRN]", "[History]", _
"[MRN] = '" & Me!txtMRN & "'")) Then
MsgBox "No history records on file for MRN " & Me!txtMRN
Else
... <open the form>
End If

John W. Vinson[MVP]
 
V

vircalendar via AccessMonster.com

Thanks. This should do the trick.

Can you point me to an overview of recordsets and recordset clones? They
come up a lot, but my grasp of how to use them effectively is pretty weak. I
tried doing some searches on this site (and the microsoft support site), but
all I find is very detailed discussions of very specific applications.

RTA

John said:
If the number is not not found, I don't want the history form
to open at all, but rather to have a simple message that no matching record
was found. Like I said - it seems pretty easy. Still, I'm stuck.

The simplest way would be to either open a Recordset (if you're
defining a query to select the history records) or use DLookUp to look
up a record in the history table; if no record is found issue an error
message. E.g.

If IsNull(DLookUp("[MRN]", "[History]", _
"[MRN] = '" & Me!txtMRN & "'")) Then
MsgBox "No history records on file for MRN " & Me!txtMRN
Else
... <open the form>
End If

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