Opening and populating a premade Report with a DAO recordset.

C

chibi_vb

I can access the fields I need from the SQL query, but I am having trouble
opening up the premade report and populating it.

Note: sSQL is a functioning SQL query

dim db As DAO.Database
dim rSet As DAO.Recordset
set db As = CurrentDB
set rSet = db.OpenRecordset(sSQL, dbOpenSnapShot)

If rSet.RecordCount = 0 Then
MsgBox "There are 0 records", vbExclamation, "No Records"
Else
' What to do here??

End If



I can exact the specific data from the recordset for a specifc field. I
need to be able to set the following:
-text fields
-checkboxes

anybody out there that can help with this problem?

Also, need to know how to a printing/no printing option for the report for
when it opens or close (either or..).
 
K

Klatuu

You do not need to create a recordset when you want to open a report.
You query should be the record source of the report.
For your text boxes and check boxes, you bind them to fields in the report's
record source.

Reports have a No Data event that fires if there are no matching records.
You can present your error message in that event. But, be aware that since
it cancels the report, the procedure where the report is opened will raise an
error 2501, so you need to use error handling to ignore the error at that
point.

As to actuall opening the report, look in VBA Help for the OpenReport
method. It is explained very well there.
 
C

chibi_vb

Problem, the info was originally extracted from another form. Cannot do this
using the basic open report scheme.

The recordset is mandatory.
 
C

chibi_vb

Error is 2451, it cannot find the customized report that exists in the same
Access DB.
 

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