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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can column position br used in Update query SQL statement?

Status
Not open for further replies.

VicM

Programmer
Sep 24, 2001
444
US
Using a SQL statement to perform an update to a recordset, can you use the column/field position to set the value instead of the field name?
I've tried several variations, but can't seem to get it to work.

Thanks,
Vic
 
Yes you can, but I think the column position property starts at zero instead of 1, maybe that is causing your problem.
 
I believe you are correct, but I'm having difficulty structuring the SQL update statement.

I've tried:
Code:
strSQL = "UPDATE tblImport SET Fields(0) = 5 WHERE MemNum = 345;"
DoCmd.RunSQL(strSQL)

But that doesn't work. I also used .Fields(0), tblImport.Fields(0), Columns(0) and tblImport.Columns(0) and none of them work. I'm getting a syntax error in SQL statement.

Of course, when I replace the Fields(0) with the field name it works as expected.

Any thoughts?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top