Adam McReynolds
Registered User.
- Local time
- Today, 11:21
- Joined
- Aug 6, 2012
- Messages
- 129
I have a form I want to close but somehow the codes running before it cancel it out before my closing code can run. Here is the full code for the form.
This is the ending code that will not run:
Any help would be much appreciated.
Code:
'Check for Null Fields
If IsNull(Me.cmb_to_customer) Or IsNull(Me.cmb_from_customer) Then
MsgBox ("Please enter a TO CUSTOMER and FROM CUSTOMER to continue.")
Cancel = True
Exit Sub
End If
If IsNull(Me.txt_qty) Or IsNull(Me.txt_trans_date) Then
MsgBox ("There is an empty Quantity or Transaction Date. Please enter these fields to continue.")
Cancel = True
Exit Sub
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Check to verify to Update batteries and Log In
If MsgBox("You are about to Log-In batteries. Do you want to continue?", vbOKCancel, "BATTERY LOG-IN") = vbCancel Then
Cancel = True
Exit Sub
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''
'INSERTS TO TABLES
'TO CUSTOMER INSERT
'If OK then SQL INSERT Into Action Table
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO TBL_ACTION ([ActionEntity], [Action], [Qty], [StockType], [DateTransaction], [Notes], [TimeStamp]) Values ('" & Me.cmb_to_customer & "', ""IN"", " & Me.txt_qty & ", '" & Me.cmb_stock_type & "', #" & Me.txt_trans_date & "#, '" & Me.txt_login_notes & "', Now() );"
DoCmd.SetWarnings True
Me.Refresh
'FROM CUSTOMER INSERT
'If OK then SQL INSERT Into Action Table
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO TBL_ACTION ([ActionEntity], [Action], [Qty], [StockType], [DateTransaction], [Notes], [TimeStamp]) Values ('" & Me.cmb_from_customer & "', ""OUT"", " & Me.txt_qty & ", '" & Me.cmb_stock_type & "', #" & Me.txt_trans_date & "#, '" & Me.txt_login_notes & "', Now() );"
DoCmd.SetWarnings True
Me.Refresh
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Case basis for payback or release table log. Keep track of who owes to who and alpha releases.
On Error GoTo Err_Command113_Click
Select Case Me.cmb_from_customer
Case "IA"
DoCmd.CancelEvent
Case "IM"
DoCmd.CancelEvent
Case Else
If Me.chk_release = True Then
'If FLAGGED AS RELEASE then SQL INSERT Into Release Log Table
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO TBL_RELEASE_LOG([ReleaseTo], [Qty], [PO], [TimeStamp], [Notes]) Values ('" & Me.cmb_to_customer & "', " & Me.txt_qty & ",'" & Me.txt_po & "', Now(), '" & Me.txt_login_notes & "' );"
DoCmd.SetWarnings True
Me.Refresh
Else
'If REGUALR TRANSFER OR LOG-IN then SQL INSERT Into Payback Table
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO TBL_PAYBACK ([Borrower], [CustomerOwed], [AmountBorrowed], [Status], [TimeStamp], [Notes]) Values ('" & Me.cmb_to_customer & "', '" & Me.cmb_from_customer & "', " & Me.txt_qty & ", ""Open"", Now(), '" & Me.txt_login_notes & "' );"
DoCmd.SetWarnings True
Me.Refresh
Cancel = True
Exit Sub
End If
End Select
Exit_Command113_Click:
Exit Sub
Err_Command113_Click:
MsgBox Err.Description
Resume Exit_Command113_Click
''''''''''''''''''''''''''''''''
'Continue or Not, If yes then wipe all fields, If no then exit form
If MsgBox("Do you want to log-in/transfer more batteries?", vbOKCancel, "BATTERY LOG-IN/TRANSFER") = vbCancel Then
DoCmd.Close acForm, "FRM_LOGIN"
Else
Me.cmb_from_customer = Null
Me.cmb_to_customer = Null
Me.txt_qty = Null
Me.chk_release = Null
Me.txt_po = Null
Me.txt_login_notes = Null
Me.Refresh
Cancel = True
Exit Sub
End If
This is the ending code that will not run:
Code:
''''''''''''''''''''''''''''''''
'Continue or Not, If yes then wipe all fields, If no then exit form
If MsgBox("Do you want to log-in/transfer more batteries?", vbOKCancel, "BATTERY LOG-IN/TRANSFER") = vbCancel Then
DoCmd.Close acForm, "FRM_LOGIN"
Else
Me.cmb_from_customer = Null
Me.cmb_to_customer = Null
Me.txt_qty = Null
Me.chk_release = Null
Me.txt_po = Null
Me.txt_login_notes = Null
Me.Refresh
Cancel = True
Exit Sub
Any help would be much appreciated.