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

AddNew method 1

Status
Not open for further replies.

Taff07

MIS
Jul 18, 2001
160
GB
Hi,

Can someone help at all with this problem.

Below is a bit of code I`m using to add a new record to a table. What I am trying to do is cycle through each field I wish to add data to with out actually naming it in this part of the code. The problem Ive got is I cant get the coding '!Fields(lngcounter)' to register unless I put the actual name of the field in here. Does anyone know how to feed a variable into this part of the code? I would e most grateful as this will save me a massive amount of work otherwise.

Thanks in advance.

Ian

------------------------------
With rstTargetTable

.AddNew

Do Until lngcounter = lngNumFields


!Fields(lngcounter) = rstlinkedImport.Fields(lngcounter).Value

lngcounter = lngcounter + 1

Loop

.Update

End With
----------------------------------
 
I think that the problem is that the "!" should be a "."
[tt]
.Fields(lngcounter) = rstlinkedImport.Fields(lngcounter).Value
[/tt]
 
Thanks dalchri,

I could have sworn i`d tried that as both . and ! but I guess i hadn`t :)

Thanks again :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top