Re: Pass Field Name Using Variable to SQL string
- From: Tom van Stiphout <tom7744.no.spam@xxxxxxx>
- Date: Fri, 21 Nov 2008 21:16:32 -0700
On Fri, 21 Nov 2008 17:54:22 -0800, Ross
<Ross@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
First of all, you have a HORRIBLE database design, which violates
important database design principles such as the "repeating group"
principle. So why not first fix that elephant in the room?
Chances are I did not convince you, so here goes:
..Fields(varFieldName).Value = dblAmount
-Tom.
Microsoft Access MVP
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:
- References:
- Pass Field Name Using Variable to SQL string
- From: Ross
- Pass Field Name Using Variable to SQL string
- Prev by Date: RE: Subforms
- Next by Date: New to Access & DB's
- Previous by thread: Pass Field Name Using Variable to SQL string
- Next by thread: Re: Pass Field Name Using Variable to SQL string
- Index(es):
Relevant Pages
|