Parameter Query To Default Value Form Field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a parameter query that asks for a date to filter by. I have a form
that uses this query to enter data into the main table. I would like the
parameter that the user enters (date) to then become the default value in the
forms' "date" field.
Any thoughts?
Thanks!
 
I would have the user enter the date on the form first, then click a button
to "get records". I'd have the query use the date from the form (instead of
the other way around).

Rick B
 
Hi, CTJ.

I don't know whether what is entered in a parameter query dialog is captured
to a system variable or not that you could use, but I see two options:

1) If the query returns records, then the value of the field has to match,
so use it:

Me![Date].DefaultValue = Me![Date]

I often use this technique in the AfterUpdate event when the user
typically enters
repetitive data.

2) Instead of using a parameter query, use a simple form to obtain the date,
and
place a reference to it in the Criteria row of the query, e.g.,

=Forms!frmObtainQueryDate!txtEventDate

By the way, "Date" is a reserved word in Access, the use of which can lead
to unexpected behavior. I suggest modifying it slightly.

Hope that helps.
Sprinks
 
Thanks folks,
I couldn't get #1 option of Sprinks' to work, however, I was able to work it
with a combination of the #2 option and Rick's suggestion.
Thanks again!

Sprinks said:
Hi, CTJ.

I don't know whether what is entered in a parameter query dialog is captured
to a system variable or not that you could use, but I see two options:

1) If the query returns records, then the value of the field has to match,
so use it:

Me![Date].DefaultValue = Me![Date]

I often use this technique in the AfterUpdate event when the user
typically enters
repetitive data.

2) Instead of using a parameter query, use a simple form to obtain the date,
and
place a reference to it in the Criteria row of the query, e.g.,

=Forms!frmObtainQueryDate!txtEventDate

By the way, "Date" is a reserved word in Access, the use of which can lead
to unexpected behavior. I suggest modifying it slightly.

Hope that helps.
Sprinks

cutthroatjess said:
I have a parameter query that asks for a date to filter by. I have a form
that uses this query to enter data into the main table. I would like the
parameter that the user enters (date) to then become the default value in the
forms' "date" field.
Any thoughts?
Thanks!
 
Back
Top