Display Message

A

asok

I want to display a message when the query returns
no records, how can I do this on a form?

when users open a form -> Records -> Query -> enter
criteria, if it doesn't return any records,
I would like it to display a message rathter
than leaving blank screen.

Thank you,
-Asok
 
G

Geof Wyght

Asok,
Using ADO and a stored query:
Dim con As ADODB.Connection
Dim rst As ADODB.Recordset
Set con = CurrentProject.Connection
Set rstADO = con.Execute(CommandText:="QSEL_XYZ",
options:=adCmdTable)
If rstADO.EOF = True Then
MsgBox prompt:="There aren't any records",
buttons:=vbInformation + vbOkOnly, Title:="Your app"
End If
Set rst = Nothing
Set con = Nothing

Geof.
 
A

Asok

Thanks Geof, I will try it.
-Asok
-----Original Message-----
Asok,
Using ADO and a stored query:
Dim con As ADODB.Connection
Dim rst As ADODB.Recordset
Set con = CurrentProject.Connection
Set rstADO = con.Execute(CommandText:="QSEL_XYZ",
options:=adCmdTable)
If rstADO.EOF = True Then
MsgBox prompt:="There aren't any records",
buttons:=vbInformation + vbOkOnly, Title:="Your app"
End If
Set rst = Nothing
Set con = Nothing

Geof.
.
 

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