-
Sorry for this one, Some of you may laugh some of you may think what a Pratt.........But here it goes.
What commands (code) would I use to check if a recordset contains information. Don't need to know what it contains just if it contains something??
Thanks in advance
Regards,
Rocks
-
Check EOF on the recordset just after you open it. Just to be safe you could check for BOF AND EOF to both be true.
-
rst.recordcount=0
Means no returned records
-
Let me re phrase
Thanks for your reply but after reading my own msg again, I would like to re-phrase it.
I have a recordset that is populated with various records from a DB.
It populates them one record at a time. What I would like to do is to check if a particular record is in the recordset just after the code to populate that recordset has been exe'd.
This is because I write each record to an individual file, what I do at the moment is create all the files before the SQL has run. Therefore that results in empty files if no info is contained in some records.
-
Be careful with RecordCount - it is not defined properly until all records have been traversed (rst.MoveLast or similar).
If rst.EOF and rst.BOF Then
MsgBox "Definitely no records"
Else
MsgBox "At least one record"
End If
Paul.
-
??
Will the all fields that are coming in have values? What I mean is, could you use a field to evaluate your situation?
-
Assuming you have a primary key, do a .Find (ADO) or .FindFirst (DAO) to find the value of the record you think you just added.
Better would be to set the .Index property of the recordset to "PrimaryKey" and use the .Seek method, cause it's much faster.
-
Thanks
Thanks all,
Maybe you would be able to help me out with another Q.
It is regarding Excel.
I need to lock the margins of the workbook so that they can not be changed in the print preview or page setup....
Thanks all.