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

Update Query trouble

Status
Not open for further replies.

demosoc

Technical User
Jun 3, 2008
44
US
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
 
Oh! I figured it out, I figured it out! Thanks for reading this far.
For anyone who cares, here's the final code:

UPDATE tblCE_Contacts_NF
INNER JOIN test1
ON tblCE_Contacts_NF.Access_Content_Exchange_ID=test1.Access_Content_Exchange_ID

SET
tblCE_Contacts_NF.NF_Contact = IIf(tblCE_Contacts_NF.NF_Contact=0,test1.NF_Contact,0),

tblCE_Contacts_NF.NF_Member = IIf(tblCE_Contacts_NF.NF_Member=0,test1.NF_Member,0),

tblCE_Contacts_NF.NF_History = IIf(tblCE_Contacts_NF.NF_History Like “*test1.NF_Recno*”,tblCE_Contacts_NF.NF_History,tblCE_Contacts_NF.NF_History+test1.NF_Recno),

tblCE_Contacts_NF.NF_Recno = test1.NF_Recno

WHERE (((tblCE_Contacts_NF.Access_Content_Exchange_ID)=test1.Access_Content_Exchange_ID));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top