
Using Variables for Field Names using .AddNew and .Update
Quote:
>Is there a way to variablize the RecordSet Field Name. I'm trying to
>build a generic Application for writing to a database that the user may
>want to Add/Change the Field Names and/or Add/Change the Source
>Variables written to the fields. In the sample code below I want
>variablize the L("FieldName[FieldIndex]").
>Dim Value(10) as Variant
>Dim FieldName(10) As String
>Set L = db2.OpenRecordset("ArtifactProbeData", dbOpenTable)
> L.AddNew
> While FieldIndex <= NumFields
> L("FieldName[FieldIndex]") = Value[FieldIndex]
> FieldIndex=FieldIndex+1
> L.Update
>L.Close
Hi Marc,
Recordsets have a Fields collection which can be referenced as
L.Fields(FieldName(FieldIndex))
Hope this helps,
Tim "Woof" Gray (remove NOSPAM from email address)
Join us in the Visual Basic and Database Chat every Tuesday 9:30pm EST at:
http://www.*-*-*.com/
or point MS Chat to server "publicchat.msn.com" and meet us in room
"SOFTWARE_DEV_TALKSHOP".