Heya,
This is my post in this forum and I apologise if I seem stupid or I've
asked a question that's been answered before.
I am working on an Access database for a project-ette and I need to
stop the user from displaying a report if the query behind the report
returns no records. The only problem I've encountered is that
OpenRecordset doesn't seem to like me very much. I've read the MSDN
documentation thousands of times and followed it to the letter and it
refuses to work. My code is...
Dim dbCurrentDatabase As Database
Dim rsRecordSet As RecordSet
Set dbCurrentDatabase = DBEngine.Workspaces(0).Databases(0)
Set rsRecordSet = dbCurrentDatabase.OpenRecordset("Total Sales")
rsRecordSet.MoveLast
if rsRecordSet.RecordCount = -1 Then
MsgBox "There are no entries to view. Please check your search
criteria and try again"
Exit_Subroutine
End If
'Continue with displaying the report...
Exit_Subroutine:
'Cancel displaying the report...
MSDN says that the source parameter (Total Sales - which is a query in
my DB) is compulsory for database.openrecordsets but the others are
optional. However, my error handling catches an error - "Too few
parameters. Expected parameters 2". Why is this?
I've tried using the query.OpenRecordSets and used all four parameters
that the function will accept, but it STILL wants more. Any help would
be appreciated.
Many thanks
Mark
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!