Need Query/Form Help

K

Kim

I am using a query that joins tables to load records into
a form....

If there are no records, the query does not create a blank
record.

When I load the form, the header is there nothing else, if
I put my Exit etc buttons on the footer they appear but do
not work.

How do I let the form know that if there are no records
not to let the form load? I tried ...

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef

Set db = currentdb
Set qdf = db.QueryDefs("TeamLeaderApprovalQuery")

Set rst = qdf.OpenRecordset(Forms!SignOnForm!fldEmployee)

If rst.EOF Then... blah blah blah

I also tried to start the Sub with On Error GoTo, but it
gets an error on the set rst even when there is a record.

Any help?
 
C

Cheryl Fischer

Hi Kim,

In the On Load event of your form, you can use the following code:

If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no records to display."
DoCmd.Close
End If

hth and Happy New Year,
 
G

Guest

Thanks! Happy New Year to you too!
-----Original Message-----
Hi Kim,

In the On Load event of your form, you can use the following code:

If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no records to display."
DoCmd.Close
End If

hth and Happy New Year,

--
Cheryl Fischer
Law/Sys Associates
Houston, TX




.
 

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