Using Variables for Field Names using .AddNew and .Update 
Author Message
 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".



Sun, 16 Jul 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Help with AddNew and using an Array for Field Names

2. Help with AddNew and using an Array for Field Names

3. Using variables for field names in recordset

4. Using variables instead of field names

5. using a variable to specify field name in dlookup function

6. referencing field names using a variable

7. Using variables for field names in VBA

8. How to update a field with the recordset using a string variable

9. Field Names using variables

10. Repost Code Example - using variables in field name references

11. Repost Code Example - using variables in field name references

12. Adding a record using the field names as a variable

 

 
Powered by phpBB® Forum Software