G
Guest
How so I write a SQL statement, referencing a text box from a form to a
query? Is it not something like:
[Forms!][FormName]![TextBox]?
query? Is it not something like:
[Forms!][FormName]![TextBox]?
I am using the textbox as a user imput, to imput an ID number, ex: 8143.
Then in a query, I'm trying to reference the textbox to populate one of the
fields in a new table. But access continues to give me an error saying that
it doesn't recognize the syntax [Forms]![Tirtltest][LstSite] off my form
named Tirtltest.
John Vinson said:I am using the textbox as a user imput, to imput an ID number, ex: 8143.
Then in a query, I'm trying to reference the textbox to populate one of the
fields in a new table. But access continues to give me an error saying that
it doesn't recognize the syntax [Forms]![Tirtltest][LstSite] off my form
named Tirtltest.
You are missing a !: try [Forms]![Tirtltest]![LstSite]
I wish it was just a missing !, but it's not. I don't understand why Access
won't recognize the textbox on the form. If I go to Design view of the query
calling the textbox, can I just do:
NewField: Forms![FormName]![TextBox]
I realized something...While testing the Run Query off the form into a brand
new query, when I didn't attach any table or query and simply created a field
referencing the text box, ie- Field: Site:[forms]![formname]![textbox]
worked. It came back with a datasheet giving me exactly what was in my form.
However, with the table/query attached, it got hung up with the Microsoft
Jet Database Engine not recognizing the statement. So why does access
recognize the statement with no table/query being present, but dosen't when
one is? Strange...
Here is what I got so far for my SQL:
SELECT [Forms]![tirtltest]![LstSite] AS SITE, TIRTLhourly.DATE,
TIRTLhourly.TIME, TIRTLhourly.LANE, TIRTLhourly.TOTAL, TIRTLhourly.[1],
TIRTLhourly.[2], TIRTLhourly.[3], TIRTLhourly.[4], TIRTLhourly.[5],
TIRTLhourly.[6], TIRTLhourly.[7], TIRTLhourly.[8], TIRTLhourly.[9],
TIRTLhourly.[10], TIRTLhourly.[11], TIRTLhourly.[12], TIRTLhourly.[13],
TIRTLhourly.[14], TIRTLhourly.[15], Int("3") AS TYPE
FROM TIRTLhourly
WHERE (((TIRTLhourly.DATE)=[forms]![tirtltest]![lstbegdate]) AND
((TIRTLhourly.TIME)>[forms]![tirtltest]![lstbegtime])) OR
(((TIRTLhourly.DATE)=[forms]![tirtltest]![lstenddate]));
I took the form out of the equation and put the data I wanted into a table.
I tried running the query, referencing instead the table now instead of the
form. Same exact error?
Field: Site:![field]
Can I use this statement?
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.