I don't think I stated my problem clearly. The field name is 1. Or, for
clarity, let's say the field name is FIELD1; then the code changes to
DoCmd.RunSQL "SELECT [FIELD1] FROM " & Me.tablename & ";"
Regardless, selecting the field is not the problem. The problem is
referencing the me.tablename textbox within the from portion of the sql
statement within VBA.
Douglas J. Steele said:
What's wrong with it is that Access doesn't allow it! <g>
You cannot refer to a field by its position in the SELECT portion of the
SQL
statement (you can in the ORDER BY portion, but I believe that's it). You
must use the name of the field.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
JJEWELL said:
I want to select field 1 from a table that I input in a form's textbox
(me.tablename). What is wrong with the following syntax?
DoCmd.RunSQL "SELECT [1] FROM " & Me.tablename & ";"