Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if form is empty when loaded

Status
Not open for further replies.

tburrows

Technical User
Oct 3, 2003
49
0
0
US
I have a form that uses a query for its data. The query uses a parameter input of a single letter to select records that begin with that letter. If the user selects a letter that is not in the database it returns with nothing. When the form starts the parameter reqeust opens up and when a correct letter is selected all those records show in the form. If a letter not in the database is selected the form is empty. What I want to do is if the query has no records in it the form to do a requery so that the user can try again.

Thanks
Tom
 
Hey Tom.

Place this code in your form's On Current event:

Code:
Dim rs As Recordset
Set rs = Me.RecordsetClone
    If rs.RecordCount = 0 Then
        MsgBox "Please choose another value.", vbOKOnly, "No Records"
        Me.Form.Requery
    End If
Set rs = Nothing

HTH,
Eric
 
Solved -
I created a recordset clone and if BOF and EOF are true then I close the form and then use DoCmd to open the form again.

Thanks
Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top