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?
This conversation is currently closed to new comments.
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.
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 & "(<list of columns in destination> VALUES('" & <first column to be copied> & "','" & <second column>... & ");" DoCmd SQLString
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
Access 2000 - Field Data