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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access/VBA Question

Status
Not open for further replies.

lamaar

Technical User
Jun 29, 2000
392
GB
I'm currently writing and Access (2000) DB with a graphics front end with the main bells ansd whistles coming out of a VBA package. I have a form that is linked to a query of the main table in the database. To bring up this form I want the user to click on a button. The problem is, that occasionally the resulting query may actually return no results. This results in a totally blank form with nothing on it which doesn't look too great. Could anyone tell me how I can get an if() statement to check if the query result will be empty before opening it?
ie:

if(query result has no results) then
MsgBox
Else
DoCmd.OpenForm

Thanks
Lamaar75@hotmail.com
 
Will something like this work? This is the syntax I would use with VB in Excel. I'm not sure if it would be the same.

Dim DB As Database
Dim RS As Recordset
Dim DBPath As String

DBPath = "C:\test.mdb"

Set DB = OpenDatabase(DBPath)
Set RS = DB.OpenRecordset("JUNK", dbOpenDynaset)

If RS.RecordCount > 0 Then
DoCmd.OpenForm
Else
MsgBox "Yo"
End If CharlesCook.com
ADP - PeopleSoft
ReportSmith - Crystal Reports - SQR - Query
Reporting - Interfaces - Data Mining
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top