A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Auto-fill query parameter from form



 
 
Thread Tools Display Modes
  #1  
Old May 15th, 2008, 03:30 PM posted to microsoft.public.access.forms
Mac
external usenet poster
 
Posts: 330
Default Auto-fill query parameter from form

I have form this filled out with customer information. the primary key being
the customer number. once this form is filled out, I click a button that
runs a macro to
1) query by customer number, at which point i have to enter the customer
number into parameters
2) it opens that customer's information into a more presentable form to be
printed
3) automatically prompts for printer of choice
4) after printer is chosen, the form closes and returns back to the other
form for a new entry.

Is there a way to fix step one to where I don't have to enter the employee
number into the parameters? Can I get the macro to read the current form
information and spit it out to either my more printable form (printing
selected record) or into a printable report for just that form?
  #2  
Old May 15th, 2008, 03:47 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Auto-fill query parameter from form

If your macro is using the OpenReport Action, you can use the Where
paramenter to enter the reference to the form control that has the customer
number. Remove the parameter from the query that is the report's record
source.
Here is how to set up the Where parameter:

[FieldName] = Forms!FormName!ControlName

[FieldName] is the name of the field in the report's record source query for
the customer number

FormName is the name of your form

ControlName is the name of the control on the form that has the customer
number.
--
Dave Hargis, Microsoft Access MVP


"Mac" wrote:

I have form this filled out with customer information. the primary key being
the customer number. once this form is filled out, I click a button that
runs a macro to
1) query by customer number, at which point i have to enter the customer
number into parameters
2) it opens that customer's information into a more presentable form to be
printed
3) automatically prompts for printer of choice
4) after printer is chosen, the form closes and returns back to the other
form for a new entry.

Is there a way to fix step one to where I don't have to enter the employee
number into the parameters? Can I get the macro to read the current form
information and spit it out to either my more printable form (printing
selected record) or into a printable report for just that form?

  #3  
Old May 15th, 2008, 03:59 PM posted to microsoft.public.access.forms
Mac
external usenet poster
 
Posts: 330
Default Auto-fill query parameter from form

I typed in

[Account] = Forms!New Customer Form!Account

Are the field name and controlName the same source?

"Klatuu" wrote:

If your macro is using the OpenReport Action, you can use the Where
paramenter to enter the reference to the form control that has the customer
number. Remove the parameter from the query that is the report's record
source.
Here is how to set up the Where parameter:

[FieldName] = Forms!FormName!ControlName

[FieldName] is the name of the field in the report's record source query for
the customer number

FormName is the name of your form

ControlName is the name of the control on the form that has the customer
number.
--
Dave Hargis, Microsoft Access MVP


"Mac" wrote:

I have form this filled out with customer information. the primary key being
the customer number. once this form is filled out, I click a button that
runs a macro to
1) query by customer number, at which point i have to enter the customer
number into parameters
2) it opens that customer's information into a more presentable form to be
printed
3) automatically prompts for printer of choice
4) after printer is chosen, the form closes and returns back to the other
form for a new entry.

Is there a way to fix step one to where I don't have to enter the employee
number into the parameters? Can I get the macro to read the current form
information and spit it out to either my more printable form (printing
selected record) or into a printable report for just that form?

  #4  
Old May 15th, 2008, 04:11 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Auto-fill query parameter from form

No. [Account] should be the name of the field in the report's record source
query and !Account should be the name of the control on the form. The value
in the !Account control should contain the value you want to find in the
field [Account].

There is also a syntax error. Names of objects really shouldn't have spaces
in them, but when you do, you need to surround them with brackets so Access
knows what it is. Try:

[Account] = [Forms]![New Customer Form]![Account]

--
Dave Hargis, Microsoft Access MVP


"Mac" wrote:

I typed in

[Account] = Forms!New Customer Form!Account

Are the field name and controlName the same source?

"Klatuu" wrote:

If your macro is using the OpenReport Action, you can use the Where
paramenter to enter the reference to the form control that has the customer
number. Remove the parameter from the query that is the report's record
source.
Here is how to set up the Where parameter:

[FieldName] = Forms!FormName!ControlName

[FieldName] is the name of the field in the report's record source query for
the customer number

FormName is the name of your form

ControlName is the name of the control on the form that has the customer
number.
--
Dave Hargis, Microsoft Access MVP


"Mac" wrote:

I have form this filled out with customer information. the primary key being
the customer number. once this form is filled out, I click a button that
runs a macro to
1) query by customer number, at which point i have to enter the customer
number into parameters
2) it opens that customer's information into a more presentable form to be
printed
3) automatically prompts for printer of choice
4) after printer is chosen, the form closes and returns back to the other
form for a new entry.

Is there a way to fix step one to where I don't have to enter the employee
number into the parameters? Can I get the macro to read the current form
information and spit it out to either my more printable form (printing
selected record) or into a printable report for just that form?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:00 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.