Command Button - Open report using current record

M

MikeT

Hi,

Can anyone help. I need to set up a command button that will open a report
for the current record on display on the form.

I have RecordID on my form and RecordID on the report and have used the
following expression:

DoCmd.OpenReport stDocName, acViewPreview, , "[RecordID]" = " &
Me.[RecordID],,acWindowNormal"

However when i use the command button all it does is open up the report with
the headers and no info? I am assuming that there is a problem with the
link, but i'm not sure what? The recordID is an autonumber.

There is another issue, which is I would like to be able to extract data
between two dates that are recorded on a subform, but one step at a time i
think.

Thanks for any help
 
F

fredg

Hi,

Can anyone help. I need to set up a command button that will open a report
for the current record on display on the form.

I have RecordID on my form and RecordID on the report and have used the
following expression:

DoCmd.OpenReport stDocName, acViewPreview, , "[RecordID]" = " &
Me.[RecordID],,acWindowNormal"

However when i use the command button all it does is open up the report with
the headers and no info? I am assuming that there is a problem with the
link, but i'm not sure what? The recordID is an autonumber.

There is another issue, which is I would like to be able to extract data
between two dates that are recorded on a subform, but one step at a time i
think.

Thanks for any help

Incorrect " placement.

DoCmd.OpenReport stDocName, acViewPreview, , "[RecordID] = " &
Me.[RecordID]

That's all you need if [RecordID] is a Number datatype field.
If it is text, then use:

"[RecordID] = """ & Me.[RecordID] & """"
 
A

Al Campagna

Mike,
Try...
DoCmd.OpenReport stDocName, acViewPreview, , "IDNo = " & Me.IDNO,
acWindowNormal

Your Where argument quotes were incorrect, and you had 2 commas before
the Window Mode argument.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
M

MikeT

Thanks fredg

Worked great. Any ideas how i can now open the same report, but only list
entries between two dates? ie Start and Finish dates that are recorded on a
separate form named RegDates?

Thanks
Mike



fredg said:
Hi,

Can anyone help. I need to set up a command button that will open a report
for the current record on display on the form.

I have RecordID on my form and RecordID on the report and have used the
following expression:

DoCmd.OpenReport stDocName, acViewPreview, , "[RecordID]" = " &
Me.[RecordID],,acWindowNormal"

However when i use the command button all it does is open up the report with
the headers and no info? I am assuming that there is a problem with the
link, but i'm not sure what? The recordID is an autonumber.

There is another issue, which is I would like to be able to extract data
between two dates that are recorded on a subform, but one step at a time i
think.

Thanks for any help

Incorrect " placement.

DoCmd.OpenReport stDocName, acViewPreview, , "[RecordID] = " &
Me.[RecordID]

That's all you need if [RecordID] is a Number datatype field.
If it is text, then use:

"[RecordID] = """ & Me.[RecordID] & """"
 

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

Similar Threads

Command Button Pt2 3
Add line to Subject in email 4
record Number and Customer Number 2
Access Choosing Printer VBA Access 0
open form during recordset update 1
print a specific record 1
FindRecord 1
Printing Reports 4

Top