473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
7 1399
ADezii
8,834 Expert 8TB
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
erainc
6
Thank you very much!!! Appreciate your help!!

Have a great day.
Mar 21 '07 #3
ADezii
8,834 Expert 8TB
Thank you very much!!! Appreciate your help!!

Have a great day.
Glad I could help.
Mar 21 '07 #4
erainc
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
8,834 Expert 8TB
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
erainc
6
How do I base the report from a query? Sorry Im a little confused..
Apr 11 '07 #7
ADezii
8,834 Expert 8TB
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

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

Similar topics

2
by: Kevin S. | last post by:
What's the easiest way for me to launch a simple DOS command "copy filename to filename" from Access 2000? I have tried in a macro and can't figure it out. I'll search the archives, but if...
2
by: Pete | last post by:
In Access 95/97 I used to be able to create pull down menus (File,Edit ...) from a macro. It seems there used to be some wizard for that. However in Access 2000 it seems you have to build your...
1
by: Ann Baker | last post by:
I had to take a Access 97, 2002 and 2003 test for a temp agency. One of the questions was to "filter the hospital macro to show only the hospitals associated with hospital ID #" Can't remember the...
4
by: marty3d | last post by:
Hi! I'm trying to create one query by combining several smaller UPDATE, INSERT and DELETE queries. I know this is easily done in SQL Server using GO, but I can't figure out how to do it in...
2
by: kkrizl | last post by:
I have an Access database that has a few huge tables. It was taking about 20 minutes per table to import them from another application. I used the upsize wizard to put them in a SQL server...
7
by: eskara | last post by:
I want to set a macro in a database to run when someone tries to Paste Append information into my Description table. Item # is set as the primary key in this database. The macro should look at the...
0
by: alphablackwolf | last post by:
At work I have a form that we enter data from access into, and then fax out. I have to base any code I do off of the form itself, so I cannot create the form from access. What I want to do is...
1
by: sphinney | last post by:
All, I'm not sure how to adequately explain my problem in two sentences or less, so at the risk of providing TMI, here's the condensed verion. I have developed an Access 2002 database file that...
4
by: kpfunf | last post by:
When I email a report via macro or vba code, the attached report is named "Fuel Quote Report.(ext)". I have no idea how this name is used. I have three seperate macros sending three seperate reports....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.