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

AddNew Method

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
----------------------------------
 
Hmmm....

Sounds like you should be using a INSERT query, not DAO....

Craig

 
:)

Thanks for your response Craig. Your right but the actual process I was trying to do wouldn`t work as I was using link tables and the specific format was incompatible so needed to drill down to the individual fields to circumvent the errors.

All sorted now though, I`d just used the ! instead of a .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top