G
Guest
Hi
I wish to append a new record to a separate table (before clearing the field
contents for re-entry) using a command box. There are no other unique fields
(the record entry form is a subform).
Ie: Append new record in [TableA] to [TableB] using [MyID] (autonumber in
[TableA]) to determine whether the current record is already in [TableB].
Per recommendation (appended below after this msg), the query runs perfectly.
Unfortunately however, [MyID] in [TableA] is an autonumber, and I believe it
is causing me to get the error message:
"Data type mismatch in criteria expression".
None of my cells are Null. Is there something I can do to make the query
read MyID not as an autonumber?
Is this the issue here? Is there a more efficient means of performing this?
Thanks in advance
Will
PS I have yet to go on VBA courses so please be gentle.
I wish to append a new record to a separate table (before clearing the field
contents for re-entry) using a command box. There are no other unique fields
(the record entry form is a subform).
Ie: Append new record in [TableA] to [TableB] using [MyID] (autonumber in
[TableA]) to determine whether the current record is already in [TableB].
Per recommendation (appended below after this msg), the query runs perfectly.
Unfortunately however, [MyID] in [TableA] is an autonumber, and I believe it
is causing me to get the error message:
"Data type mismatch in criteria expression".
None of my cells are Null. Is there something I can do to make the query
read MyID not as an autonumber?
Is this the issue here? Is there a more efficient means of performing this?
Thanks in advance
Will
PS I have yet to go on VBA courses so please be gentle.
Ken Sheridan said:You'll need to run ... an append query to insert the new rows. ...For the sake of this example I'll assume a single column non-autonumber key called MyID, so the query would go like this:
To append new rows from table A to table B you need to identify those rows
in Table B which don't exist in Table B:
INSERT INTO [Table B]
([MyID], [Field1], [Field2], [Field 3],[Field 4])
SELECT [MyID], [Field1], [Field2], [Field 3],[Field 4]
FROM [Table A]
WHERE NOT EXISTS
(SELECT *
FROM [Table B]
WHERE [TableB].[MyID] = [TableA].[MyID];