Error for record not found to report to user

R

Rpatton

Hi all,

Background:

If you have a search which is part of a form. It looks information up in a
snap shot query which is a summary of another tabel (SA table) based on a
key found in another teh Roster table. There may be more discrete enteries
in the roster tabel than in the SA table. If records do not exist in the in
teh SA sanp shot i would like to detect this and reprt to the user that they
need to create a new record for the ID.

Question:

How do i detect that no records were found so I can print a message?

Thanks in advance,

Dick
 
J

John Nurick

Hi Dick,

Probably the thing to do is to use DCount() on the query first to see if
it will return any records, e.g. something like

If DCount("*", "MyQuery) = 0 Then
MsgBox "You need to create a new record", _
vbInformation + vbOKOnly
Else
...
End If
 
R

Rpatton

Thankyou John,

I decided to try to assess the field and trap the error in my code. By
doing so access does the chaeck for me and tells me that there is no such
field.

I think that's 2724.

Happy New Year John.

Dick
 

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