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

How do I check if any records were selected?

Status
Not open for further replies.

EdAROC

Programmer
Aug 27, 2002
93
US
After the statement:
Set rs = db.OpenRecordset(strSQL)
executes I would like to check to see if any records were selected, if not (no records selected) then display an appropriate message and exit.

What is the statement to check if any records were selected? If records were not selected what statements should be included to properly close anything opened (i.e. by the OpenRecordSet)

Here's is some of the code (stripped out some irrelevant details)

Code:
Private Sub cmdCreateFile_Click()
   
   On Error GoTo Err_cmdCreateFile_Click
   
   Dim intCkSum As Byte
   Dim db As Database
   Dim nH As Integer
   Dim rs As Recordset
   Dim Buffer As String, strSQL As String
   
   *(code removed from these tasks)
   'Init
   'Clear ErrMsg in case user had to correct input
   'Check That Dates Are Valid

   'Select Records
   strSQL = "SELECT APCHECK.APCHNUM, {code removed}

   Set db = CurrentDb
   Set rs = db.OpenRecordset(strSQL)

*** At this point I want to check to see if any records were selected. If so then continue with the process, if not then exit - closing anything left open ***
 
You can make a seltec count statement

I will try my best to help others so will others do!!!!!
IGPCS
Brooklyn, NY
 
oh i didnt get your question so yes its like Barny said but after the msgbox "your message" in the next line type Exit Sub



I will try my best to help others so will others do!!!!!
IGPCS
Brooklyn, NY
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top