By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

I'm new to Access and can't figure out what Macro to run

P: 6
Hi There,

I am a new user to Access 2003 and I have created a command button on my form to print the report version of the form. I want only the current record to print when the user clicks on the print button.

I've created the Macro, but in the Where Condition (of the Macro) I can NOT figure out for the life of me on how to restrict to print only the current record..
I know this sounds probably very 1st grader to most you, but I can not figure it out!!!! Can anyone out there help?????????????

Thank you VERY much for taking the time to read this...

Hope you are all having a great day.
Mar 20 '07 #1
Share this Question
Share on Google+
7 Replies


ADezii
Expert 5K+
P: 8,627
Hi There,

I am a new user to Access 2003 and I have created a command button on my form to print the report version of the form. I want only the current record to print when the user clicks on the print button.

I've created the Macro, but in the Where Condition (of the Macro) I can NOT figure out for the life of me on how to restrict to print only the current record..
I know this sounds probably very 1st grader to most you, but I can not figure it out!!!! Can anyone out there help?????????????

Thank you VERY much for taking the time to read this...

Hope you are all having a great day.
You don't have to bother with either a Macro or a WHERE condition. If the Reports is based on a Query, and you only want to Print the Report for the Current Record being shown on the Form:
__1. In the underlying Record Source (Query) for your Form, set a Criteria on the Primary Key Field equal to:
Expand|Select|Wrap|Line Numbers
  1. [Forms]![<Your Form Name>]![< Your PrimaryKey Field>]
Be sure the Primary Key Fields exists on the Form. Now, in the Click() Event of a Command Button on the Form:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "<Your Report Name>", acViewPreview, , , acWindowNormal
Mar 21 '07 #2

P: 6
Thank you very much!!! Appreciate your help!!

Have a great day.
Mar 21 '07 #3

ADezii
Expert 5K+
P: 8,627
Thank you very much!!! Appreciate your help!!

Have a great day.
Glad I could help.
Mar 21 '07 #4

P: 6
Hi there,

I was just going over your last post to my question.

The form that I put the command print button on is not based on a query, it is based on a table. Does that matter? Right now the code for the print button reads the below:


Private Sub Print_Rpt_Cmd_Button_Click()
On Error GoTo Err_Print_Rpt_Cmd_Button_Click

Dim stDocName As String

stDocName = "Rpt_Updated_Alumni_Summry"
DoCmd.OpenReport stDocName, acNormal


Exit_Print_Rpt_Cmd_Button_Click:
Exit Sub

Err_Print_Rpt_Cmd_Button_Click:
MsgBox Err.Description
Resume Exit_Print_Rpt_Cmd_Button_Click

End Sub


BUT, this print the whole report and I only want it to print the current record from the report (not the form). The button is on the form.....

Thanks for any help or advice you can give me!!!
Apr 11 '07 #5

ADezii
Expert 5K+
P: 8,627
Hi there,

I was just going over your last post to my question.

The form that I put the command print button on is not based on a query, it is based on a table. Does that matter? Right now the code for the print button reads the below:


Private Sub Print_Rpt_Cmd_Button_Click()
On Error GoTo Err_Print_Rpt_Cmd_Button_Click

Dim stDocName As String

stDocName = "Rpt_Updated_Alumni_Summry"
DoCmd.OpenReport stDocName, acNormal


Exit_Print_Rpt_Cmd_Button_Click:
Exit Sub

Err_Print_Rpt_Cmd_Button_Click:
MsgBox Err.Description
Resume Exit_Print_Rpt_Cmd_Button_Click

End Sub


BUT, this print the whole report and I only want it to print the current record from the report (not the form). The button is on the form.....

Thanks for any help or advice you can give me!!!
You must base the Report in order for this to work correctly. It is a simple matter to create a Query that parallels the Table.
Apr 11 '07 #6

P: 6
How do I base the report from a query? Sorry Im a little confused..
Apr 11 '07 #7

ADezii
Expert 5K+
P: 8,627
How do I base the report from a query? Sorry Im a little confused..
  • Query ==> New ==> Design View ==> Select Table Report is based on.
  • Drop all Fields from the Table onto the Query Grid.
  • Set the criteria on the 1 Field as previously shown
  • Name the Query
  • In the properties of the Report, set the Control Source = the Query you just created.
Apr 11 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.