I’m trying to create an update query where a table (tblCE_Contacts_NF) is updated based on a different query (test1). I’m new to update queries (and new to Access for that matter) and am having trouble with the coding. I’m running Microsoft Access 2003. Any help is greatly appreciated!
The fields are named the same in the table (tblCE_Contacts_NF) and the query (test1) and share the same types, which are :
Access_Content_Exchange_ID – number
Email_Address – Text
NF_Contact - Boolean
NF_Recno - Text
NF_History - Memo
NF_Member - Boolean
Here’s the Code I’ve written which doesn’t work:
‘Change the table
UPDATE tblCE_Contacts_NF
SET
‘Change Boolean to True if False, else leave it
tblCE_Contacts_NF2.NF_Contact = IIF(tblCE_Contacts_NF2.NF_Contact = 0, test1.NF_Contact,0)
‘Change Boolean to True if False, else leave it
tblCE_Contacts_NF2.NF_Member = IIF(tblCE_Contacts_NF2.NF_Member = 0, test1.NF_Member
,0)
‘If text not already in memo, add to memo
tblCE_Contacts_NF2.NF_History = IIF(tblCE_Contacts_NF2.NF_History Like ‘*test1.NF_History*’, tblCE_Contacts_NF2.NF_History, tblCE_Contacts_NF2.NF_History+ test1.NF_History)
‘update
tblCE_Contacts_NF2.NF_Recno = test1.NF_Recno
INNER JOIN tblCE_Contacts_NF2.Access_Content_Exchange_ID= test1.Access_Content_Exchange_ID
The fields are named the same in the table (tblCE_Contacts_NF) and the query (test1) and share the same types, which are :
Access_Content_Exchange_ID – number
Email_Address – Text
NF_Contact - Boolean
NF_Recno - Text
NF_History - Memo
NF_Member - Boolean
Here’s the Code I’ve written which doesn’t work:
‘Change the table
UPDATE tblCE_Contacts_NF
SET
‘Change Boolean to True if False, else leave it
tblCE_Contacts_NF2.NF_Contact = IIF(tblCE_Contacts_NF2.NF_Contact = 0, test1.NF_Contact,0)
‘Change Boolean to True if False, else leave it
tblCE_Contacts_NF2.NF_Member = IIF(tblCE_Contacts_NF2.NF_Member = 0, test1.NF_Member
,0)
‘If text not already in memo, add to memo
tblCE_Contacts_NF2.NF_History = IIF(tblCE_Contacts_NF2.NF_History Like ‘*test1.NF_History*’, tblCE_Contacts_NF2.NF_History, tblCE_Contacts_NF2.NF_History+ test1.NF_History)
‘update
tblCE_Contacts_NF2.NF_Recno = test1.NF_Recno
INNER JOIN tblCE_Contacts_NF2.Access_Content_Exchange_ID= test1.Access_Content_Exchange_ID