After updating a certain field I need to check if that value exists in a separate table/field. If it does I need to do nothing, but if it doesn't I would like to create a new record and add in this value.
At the moment I have the below - which doesnt work. I am clutching at straws as I guess I need to set up a recordset - but I do not know how.
Private Sub FileNo_AfterUpdate()
Dim rst As Recordset
Dim Box As String
If IsNull(DLookup("HSBCBoxNo", "Tbl_convert", "HSBCBoxNo = Forms!FRM_InputRecord!FRM_InputRecordSubform!FileNo"
) Then
Forms!FRM_InputRecord!Frm_InputRecordSubform!FileNo = Box
With rst
.AddNew ' Add new record.
!FileNo = Box ' Add data.
.Update ' Save changes.
End With
Else
End If
End Sub
At the moment I have the below - which doesnt work. I am clutching at straws as I guess I need to set up a recordset - but I do not know how.
Private Sub FileNo_AfterUpdate()
Dim rst As Recordset
Dim Box As String
If IsNull(DLookup("HSBCBoxNo", "Tbl_convert", "HSBCBoxNo = Forms!FRM_InputRecord!FRM_InputRecordSubform!FileNo"
Forms!FRM_InputRecord!Frm_InputRecordSubform!FileNo = Box
With rst
.AddNew ' Add new record.
!FileNo = Box ' Add data.
.Update ' Save changes.
End With
Else
End If
End Sub