Pass Query Paramater to populate form

  • Thread starter Thread starter ricky
  • Start date Start date
R

ricky

Good Morning Everyone

I have a query which executed from a command button, which contains a
parameter.

Is it possible to pass this parameter back to the form?

Kind Regards

Ricky
 
I don't know if you can if it's an Access generated parameter window. I know
that you could create your *own* parameter window by creating a dialog box,
and pass the parameter to your form that way.
 
Could you create a text box in the form that gets the parameter first? Then
your query would run based on the text box value and you'll have the
parameter available for other things. Just use something like the following
in the query criteria instead of what you currently have for the parameter:

[Forms]![FormName]![TextBox1]
or using wildcards:
Like "*" & [Forms]![FormName]![TextBox1] & "*"
 
The only issue, is, is that the query runs a returns a record as a form
record, I cannot seem to reproduce that if I run my own query, through
OpenQuery method?

The form has a command button and the user presses this and it runs a macro,
which contains a query with a parameter, which is supplied from the prompt.
After the query finishes, the record is displayed in the form.

Does that make sense?

Kind Regards

Ricky

kingston via AccessMonster.com said:
Could you create a text box in the form that gets the parameter first? Then
your query would run based on the text box value and you'll have the
parameter available for other things. Just use something like the following
in the query criteria instead of what you currently have for the parameter:

[Forms]![FormName]![TextBox1]
or using wildcards:
Like "*" & [Forms]![FormName]![TextBox1] & "*"
Good Morning Everyone

I have a query which executed from a command button, which contains a
parameter.

Is it possible to pass this parameter back to the form?

Kind Regards

Ricky
 
It doesn't sound like this will be a problem. All you're doing is replacing
the source of the parameter - from a temporary dialog window to a control on
a form. In your macro, use a conditional to check that something is in the
textbox first: Forms![FormName]![TextBox1] <>"". Or if it is ="", display a
message for the user to enter something in the textbox. If you really want
to clean this up, get rid of the button, and use the textbox's AfterUpdate
event to trigger the macro.
The only issue, is, is that the query runs a returns a record as a form
record, I cannot seem to reproduce that if I run my own query, through
OpenQuery method?

The form has a command button and the user presses this and it runs a macro,
which contains a query with a parameter, which is supplied from the prompt.
After the query finishes, the record is displayed in the form.

Does that make sense?

Kind Regards

Ricky
Could you create a text box in the form that gets the parameter first? Then
your query would run based on the text box value and you'll have the
[quoted text clipped - 15 lines]
 
Hi Kingston

Okay, I'll try substituting the parameter prompt from the query, by using
the value in the textbox, and see if that works... will let you know how I
get on.

Thanks.

Kind Regards
Ricky

kingston via AccessMonster.com said:
It doesn't sound like this will be a problem. All you're doing is replacing
the source of the parameter - from a temporary dialog window to a control on
a form. In your macro, use a conditional to check that something is in the
textbox first: Forms![FormName]![TextBox1] <>"". Or if it is ="", display a
message for the user to enter something in the textbox. If you really want
to clean this up, get rid of the button, and use the textbox's AfterUpdate
event to trigger the macro.
The only issue, is, is that the query runs a returns a record as a form
record, I cannot seem to reproduce that if I run my own query, through
OpenQuery method?

The form has a command button and the user presses this and it runs a macro,
which contains a query with a parameter, which is supplied from the prompt.
After the query finishes, the record is displayed in the form.

Does that make sense?

Kind Regards

Ricky
Could you create a text box in the form that gets the parameter first? Then
your query would run based on the text box value and you'll have the
[quoted text clipped - 15 lines]
 
Back
Top