Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

Auto-fill query parameter from form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mac - 15 May 2008 15:30 GMT
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?
Klatuu - 15 May 2008 15:47 GMT
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.
Signature

Dave Hargis, Microsoft Access MVP

> 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
[quoted text clipped - 11 lines]
> information and spit it out to either my more printable form (printing
> selected record) or into a printable report for just that form?
Mac - 15 May 2008 15:59 GMT
I typed in

[Account] = Forms!New Customer Form!Account

Are the field name and controlName the same source?

> 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
[quoted text clipped - 27 lines]
> > information and spit it out to either my more printable form (printing
> > selected record) or into a printable report for just that form?
Klatuu - 15 May 2008 16:11 GMT
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]

Signature

Dave Hargis, Microsoft Access MVP

> I typed in
>
[quoted text clipped - 33 lines]
> > > information and spit it out to either my more printable form (printing
> > > selected record) or into a printable report for just that form?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.