Performing a query based on the value of an unbound text box...

G

Guest

Anyone,
I'm trying to define the criteria for a date field in a query based on the
value of a text box based on input by the user. The default value for the
text box (txtbxInputDate) is Now() so on launching the screen, the form data
should query = to today's date. If the txtbxInputDate is changed then the
txtbxInputDate.Update event is fired, then I am executing a line of VB code
Me.Requery. Both instances the query is not recognizing the value in the
txtbxInputDate. Access pops-up a window for you to input the date you want
for Me.txtbxInputDate.Value when there is already a value in the text
box????? My date field query criteria is:
(([Me].[txtbxInputDate].[Value])). Tks for any help...
 
F

fredg

Anyone,
I'm trying to define the criteria for a date field in a query based on the
value of a text box based on input by the user. The default value for the
text box (txtbxInputDate) is Now() so on launching the screen, the form data
should query = to today's date. If the txtbxInputDate is changed then the
txtbxInputDate.Update event is fired, then I am executing a line of VB code
Me.Requery. Both instances the query is not recognizing the value in the
txtbxInputDate. Access pops-up a window for you to input the date you want
for Me.txtbxInputDate.Value when there is already a value in the text
box????? My date field query criteria is:
(([Me].[txtbxInputDate].[Value])). Tks for any help...

1) you cannot use the Me keyword in Access (Query, Form, Report), only
in VBA.

2) Using Now() as default value is going to restrict the date to not
only the day but the exact time the query is run as well.
Use Date() instead.

3) Your criteria is incorrectly written.
As criteria in the query use:
forms!FormName!txtbxInputDate
(Change FormName to the actual name of your form)

4) Why Requery?

5) Value is the default property, so you do not need to explicitly
write it.

6) The form must be open when the query is run.
 
G

Guest

Fred,
Thanks for the help. To answer your questions:
1) Thanks for the info. on Me.
2) I did have date() but changed it to Now() trying to get the query to
execute
with the right behavior.
3) What is the difference between forms!formname!txtbxInputDate and
forms.formsname.txtbxInputDate?
4) For some reason, when you change the value of the the unbound
txtbxInputDate, the OnUpdate isn't working or something using the
Me.Requery. I put a cmdbtn next to the text box so the user can
click it. It
executes the Me.Requery and behaves now the way I want it to work.
Tks for the help,
Don
=====================================================

fredg said:
Anyone,
I'm trying to define the criteria for a date field in a query based on the
value of a text box based on input by the user. The default value for the
text box (txtbxInputDate) is Now() so on launching the screen, the form data
should query = to today's date. If the txtbxInputDate is changed then the
txtbxInputDate.Update event is fired, then I am executing a line of VB code
Me.Requery. Both instances the query is not recognizing the value in the
txtbxInputDate. Access pops-up a window for you to input the date you want
for Me.txtbxInputDate.Value when there is already a value in the text
box????? My date field query criteria is:
(([Me].[txtbxInputDate].[Value])). Tks for any help...

1) you cannot use the Me keyword in Access (Query, Form, Report), only
in VBA.

2) Using Now() as default value is going to restrict the date to not
only the day but the exact time the query is run as well.
Use Date() instead.

3) Your criteria is incorrectly written.
As criteria in the query use:
forms!FormName!txtbxInputDate
(Change FormName to the actual name of your form)

4) Why Requery?

5) Value is the default property, so you do not need to explicitly
write it.

6) The form must be open when the query is run.
 

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