Discussion Locked

Access 2000 - Field Data

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I want to read a record and append that record to another table. However, I want the destination table name to be the data found in a field within the origional record. Is there any way I can use the data in a field as the destination table name?

5 replies

by john_wills

Use the destination-nameing field to construct a string containing the name of the destination table. Put this string in a larger string with a SQL INSERT command using the appendend data as constants. DoCmd.RunSQL on that longer string.

by john_wills

Put the SELECT for the table you want to read in a string and use that string as parameter when opening a RecordSet:
Set ReadTable = CurrentDb().OpenRecordset(ReadSQL)
ReadTable.MoveFirst ' MoveNext the next time
DestTableName = ReadTable.Fields(0) 'I here suppose that the destination table name is in the first column; the columns to be copied to the destination are found in their own field positions.

SQLString="INSERT INTO " & DestTableName & "() VALUES('" & & "','" & ... & ");"
DoCmd SQLString

Make this into a loop.

This discussion is closed to new replies.