Auto-fill query parameter from form

M

Mac

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?
 
K

Klatuu

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.
 
M

Mac

I typed in

[Account] = Forms!New Customer Form!Account

Are the field name and controlName the same source?

Klatuu said:
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 said:
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?
 
K

Klatuu

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 said:
I typed in

[Account] = Forms!New Customer Form!Account

Are the field name and controlName the same source?

Klatuu said:
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 said:
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?
 

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