I have an AfterUpdate code that uses the DLookup function to find the matching record in a corresponding table.
If the matching record exists, the field is changed to the correct value based on DLookup of corresponding table.
Here is my problem:
If matching record does not exists the current data (or is not found in the table) is removed/erased.
I need the current data that was entered not to be erased. Maybe something like:
If matching record does not exists ask user do they wish to change/overide the current data (Yes/No Message Box):
If Yes, removed the current data and Me.ConsigneeID.SetFocus
If No, leave data unchanged.
Any help would be appreciated….
‘-----------------------------------------------------
Private Sub SpecNo_AfterUpdate()
On Error GoTo Err_SpecNo_AfterUpdate
Dim strFilter As String
strFilter = "CODE = " & Me!SpecNo
Me!ConsigneeID = DLookup("CENTRE", "CodeLook", strFilter)
If IsNull(DLookup("CENTRE", "CodeLook", strFilter)) Then
MsgBox "Match Not Found. Continue or Enter a vaild Cost Centre?", vbOKOnly + vbInformation, "Default Consignee"
Else
MsgBox "Match Found", vbInformation, "Default Consignee"
End If
Exit_SpecNo_AfterUpdate:
Exit Sub
Err_SpecNo_AfterUpdate:
MsgBox Err.Description
Resume Exit_SpecNo_AfterUpdate
End Sub
‘--------------------------------------------------------
Any help would be appreciated….
If the matching record exists, the field is changed to the correct value based on DLookup of corresponding table.
Here is my problem:
If matching record does not exists the current data (or is not found in the table) is removed/erased.
I need the current data that was entered not to be erased. Maybe something like:
If matching record does not exists ask user do they wish to change/overide the current data (Yes/No Message Box):
If Yes, removed the current data and Me.ConsigneeID.SetFocus
If No, leave data unchanged.
Any help would be appreciated….
‘-----------------------------------------------------
Private Sub SpecNo_AfterUpdate()
On Error GoTo Err_SpecNo_AfterUpdate
Dim strFilter As String
strFilter = "CODE = " & Me!SpecNo
Me!ConsigneeID = DLookup("CENTRE", "CodeLook", strFilter)
If IsNull(DLookup("CENTRE", "CodeLook", strFilter)) Then
MsgBox "Match Not Found. Continue or Enter a vaild Cost Centre?", vbOKOnly + vbInformation, "Default Consignee"
Else
MsgBox "Match Found", vbInformation, "Default Consignee"
End If
Exit_SpecNo_AfterUpdate:
Exit Sub
Err_SpecNo_AfterUpdate:
MsgBox Err.Description
Resume Exit_SpecNo_AfterUpdate
End Sub
‘--------------------------------------------------------
Any help would be appreciated….