Inserting a Date into existing query in Form

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

Guest

I have a form that has a hard coded query that returns results and would like
to have a textbox that takes a date in and uses that date instead of the hard
coded date that is there now. I have the textbox on the form with the button
that runs the query, how would i go about using the textbox info to insert
that info into the query?
 
If I understood you then you want to insert a date that you input in a text
box into a table using a query.
if so then on the click of the button you write

declare MySql as string
if not isnull(Me.textBxo ) then
MySql= "UPDATE MyTable2 SET MyTable2.StartDate = #" & Me.textBxo & "#
Where ...."
else
msgbox "NoDate"
endif

docmd.runsql MySql
 
Rick,
Thanks for your help, it works to a point so my next question is why is it
doing it this way now. When i entered {form1}![Text2} in the query area and
when i goto the form and enter date and click on the button to run query i
get an error stating "invalid sequel statement: expected "Delete" "Insert"
"Procedure" "select" or "Update".
When i click on the query in the query area a window opens to enter
parameter value and i enter the date there and the query works fine.

Rick B said:
Replace your query hard-coded criteria with...


=Forms![MyFormName]![MyFieldName]


--
Rick B



Dan N said:
I have a form that has a hard coded query that returns results and would like
to have a textbox that takes a date in and uses that date instead of the hard
coded date that is there now. I have the textbox on the form with the button
that runs the query, how would i go about using the textbox info to insert
that info into the query?
 

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

Back
Top