Msgbox help

jbphoenix

Registered User.
Local time
Today, 13:27
Joined
Jan 25, 2007
Messages
98
My database is for creating labels for finished goods. If the admin needs to add a part to the database they need to enter the necessary info in a form. However I would like a query to run on the form load and if the results of the query is nothing but a blank datasheet I would like a msgbox to open telling them to check the ERP system for the part status. However I'm not sure how to do this. I can run the query but i'm not sure how to get a msgbox to open if the datasheet is blank. Any ideas?
 
Code:
Private Sub Form_Open(Cancel as Integer)
[COLOR="Green"]  'informs the user that a particular query returns no records[/COLOR]
  dim rst as dao.recordset
  set rst = currentdb.openrecordset("yourQuery")
  with rst
    if .recordcount = 0 then
      msgbox "Query 'yourQuery' returns no records."
    end if
    .close
  end with
  set rst = nothing
[COLOR="green"]  'informs user that the form has no records[/COLOR]
  If Me.Recordset.RecordCount = 0 Then
    Msgbox "Form has no records"
  End If
End Sub
 
That is exactly what I am looking for. It works perfectly, Thanks!
 

Users who are viewing this thread

Back
Top Bottom