send recordset to report

D

Daniel M

I have a form that submits the fields by recordset instead of bound fields.

Dim Rs As Recordset
Set Rs = CurrentDb.OpenRecordset("Assets")
Rs.AddNew
Rs![Dateentered] = Dateentered
Rs![EmployeeID] = Employees.Value
Rs.Update
Rs.Close

when i click a command button it submits the record to the table. I would
also like to send the record to a report for printing. there is now primary
key on this form. can someone help me figure out how to capture the recordset
and send it to a report?

Thanks.
 
P

Piet Linden

I have a form that submits the fields by recordset instead of bound fields.

Dim Rs As Recordset
Set Rs = CurrentDb.OpenRecordset("Assets")
Rs.AddNew
Rs![Dateentered] = Dateentered
Rs![EmployeeID] = Employees.Value
Rs.Update
Rs.Close

when i click a command button it submits the record to the table. I would
also like to send the record to a report for printing. there is  now primary
key on this form. can someone help me figure out how to capture the recordset
and send it to a report?

Thanks.

What you want is not completely clear. Do you mean you want to print
a single record in your report, or a group of records related to the
current record? If so, then just pass the filter for the current
record (pass the primary key) in the open event of the report.

See DoCmd.OpenReport

one of the arguments is a filter.

If you have a SQL statement (unfiltered), base the report on that and
filter the report in the open event to get a subset of all the records.
 
D

Daniel M

Dim Rs As Recordset
Set Rs = CurrentDb.OpenRecordset("Assets")
Rs.AddNew
Rs![Dateentered] = Dateentered
Rs![EmployeeID] = Employees.Value
Rs.Update
Rs.Close
set rs = nothing
DoCmd.GoToRecord , , acNewRec
dateentered = ""
employees =""

Problem is after i submit the data to the table i clear out the form for the
next entry. I do not have the primary key in the form because it is an auto
number and created when i write it to the table. So i need a way to send the
data to the report before i clear it. Or a way to get the primary key just
created. Another problem is this is a multiuser database so i can't just take
the last record created.

And yes i only want to print the current record to the report. I do have
more than the 2 fields listed but i simplified it for this post.

Thanks.

Piet Linden said:
I have a form that submits the fields by recordset instead of bound fields.

Dim Rs As Recordset
Set Rs = CurrentDb.OpenRecordset("Assets")
Rs.AddNew
Rs![Dateentered] = Dateentered
Rs![EmployeeID] = Employees.Value
Rs.Update
Rs.Close

when i click a command button it submits the record to the table. I would
also like to send the record to a report for printing. there is now primary
key on this form. can someone help me figure out how to capture the recordset
and send it to a report?

Thanks.

What you want is not completely clear. Do you mean you want to print
a single record in your report, or a group of records related to the
current record? If so, then just pass the filter for the current
record (pass the primary key) in the open event of the report.

See DoCmd.OpenReport

one of the arguments is a filter.

If you have a SQL statement (unfiltered), base the report on that and
filter the report in the open event to get a subset of all the records.
 

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