The db errors when opening, doesn't like some code behind the Login form but when I set a breakpoint in the Open event, the form opens as I step through code.
Your code wants to open form frm_CREATE_PACKER but I don't see a form by that name.
The code tries to create record (and fails) for AFB Farms Ltd even though it is already in the FULLPACKER table because there is a period (.) at the end of AFB Farms Ltd. in the FULLPACKER table but not in BUSINESS table.
Consider:
Code:
Private Sub AddPacker(strBUSINESS_NAME As String)
Dim Grower_lnk As Integer
Dim PackerLicence As String
If Me.Check_Packer = 0 Then
MsgBox "Please Select Packer Check Box before Proceeding"
ElseIf IsNull(DLookup("[Business Name]", "FULLPACKER", "[Business Name] = '" & strBUSINESS_NAME & "'")) Then
PackerLicence = DMax("[PLICENCE]", "FULLPACKER")
PackerLicence = PackerLicence + 1
Grower_lnk = Forms!BUSINESS_MAIN!MEMBER_ID
'Insert packer record
CurrentDb.Execute "INSERT INTO fullpacker([Business Name], PLicence, Member_ID) VALUES('" & strBUSINESS_NAME & "', '" & PackerLicence & "', '" & Grower_lnk & "')"
'Open the form based on where clause
DoCmd.OpenForm "frm_CREATE_PACKER", , , "[Business Name]='" & strBusiness_Name & "'"
MsgBox "New Packer Record Has Been Created for: " & strBUSINESS_NAME
Else
MsgBox "Packer Record for: " & strBUSINESS_NAME & " already exists, Please proceed with edit session.", vbCritical
End If
End Sub