Pass Field Name Using Variable to SQL string
- From: Ross <Ross@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 21 Nov 2008 17:54:22 -0800
I want to pass field names to an SQL string to identify the current of many
fields that I have to update in the table tblData (ie Fields ----> Jan06,
Feb06, Mar03......Dec09).
I want to use a recordset with SQL to identify the current field and edit
and update the current record in the current field.
The field is identified in the SQL as followings:
tblData." & varFieldName & " where the variable might be set to "Jan".
<----------
This syntax works perfectly in the SQL to identify the current field in the
db.openreocrdset(strsql).
The update is NOT working :
..edit
!Jan = dblAmount <---------------This works
![" & varFieldname & "] = dblAmount <----------This does not work
..update
This error message "item not found in collection" implies that it is
looking for a field "Jan" in tblData but is unable to find "Jan" which does
exists. Highlighting the variable indicates that the variable is correctly
set to Jan.
How can I make this work using variables. My syntax must be wrong? I am
using a variant variable and had the same results with a string variable.
Thanks
Ross
.
- Follow-Ups:
- Re: Pass Field Name Using Variable to SQL string
- From: Tom van Stiphout
- Re: Pass Field Name Using Variable to SQL string
- Prev by Date: RE: Multiple Combo boxes
- Next by Date: RE: Subforms
- Previous by thread: Problem with data displaying in form and layout view
- Next by thread: Re: Pass Field Name Using Variable to SQL string
- Index(es):
Relevant Pages
|