It has been a while since I have worked in Access, but I am having a problem figuring out how to code this:
A user enters a record into a form (temporary table). The program then looks for this record in an existing table and upates the remainder of the columns with the information entered.
Temp_Table (user entry)
-Serial Number (Key)
-Job Number
Main_Table (already defined)
-Serial Number (Key)
-Job Number (empty and updated form Temp_Table)
What I want to do is:
For Serial Number:
-Have the program error on a serial number entered in Temp_Table that is not in Main_Table
For Job Number:
-In the case where Main_Table is empty it updates it with the Temp_Table value (completed).
-If the Main_Table and Temp_Table Job Numbers are different (and Main is not null) an error message.
-If the Main_Table and Temp_Table Job Numbers are different an error message.
Any idea on where I can begin? Here is my code so far with no error messages or logic programmed. Thanks
'Runs great, but no logic for errors
Private Sub Append_Click()
On Error GoTo Append_Click_Err
With CodeContextObject
DoCmd.RunCommand acCmdRefresh
DoCmd.Echo True, ""
DoCmd.SetWarnings False
DoCmd.OpenQuery "Pouch_Info", acViewNormal, acEdit
DoCmd.Close acQuery, "Pouch_info"
'Queries values from temp_table
DoCmd.OpenQuery "Pouch_Update", acViewNormal, acEdit
'Updates main_table with temp_table values
DoCmd.Close acQuery, "Pouch_Update"
DoCmd.OpenReport "Pouch_Label", acViewNormal, "", "", acHidden
DoCmd.Close acReport, "Pouch_Label"
'Prints report for that record
DoCmd.OpenQuery "Purge_After_Label", acViewNormal, acEdit
'Clears temp_table
DoCmd.Close acQuery, "Purge_After_Label"
DoCmd.Requery ""
End With
Append_Click_Exit:
Exit Sub
Append_Click_Err:
MsgBox Error$
Resume Append_Click_Exit
End Sub