Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use form to change the table name in a query?

Status
Not open for further replies.

Halet

MIS
Jun 26, 2007
13
US
I am currently using form to update date ranges in my database.

Here is the sample of the query.

SELECT FAR.[SVC DATE], FAR.[ACCT BAL]FROM FAR
WHERE (((FAR.[SVC DATE]) Between Forms!frmUpdateDateRange!txtday0 And Forms!frmUpdateDateRange!txtday30));

I tried to use the similar code to change my table name from FAR to SAR. However, Access don't allow me to do that. Is there a way that I can use the form to change the table name in a query?

Thanks in advance for your inputs!
 
How are you running the query? Is it embedded in VBA code? What method have you tried to use to change the table name within the query?

-V
 
I just click the query when I run them or using macros. It is not embedded in vba code. I tried copy the sql to word and do a find and replace, but that take too much time.

Like I said, It is similar to what I do with date range. I type a date in the form's text box and I reference the text box in my sql. I would like to do the same thing with the table name because my table name is date based too.
For example, tbl0607 where 0607 equals june 07.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top