G
Gina Whipp
Hello All,
I have this on the Form_Unload event. What I want if both conditions are
true then ask the question. But if one or both of these conditions are true
then just close. I have tried the 3 condition below and none are working.
Can someone help me as to why it won't listen to me?
Thanks,
Gina Whipp
TRIED: If Form_sfrBoLDetail.Recordset.RecordCount > 0 Or Not
IsNull([cboBillOfLadingID]) Then Exit Sub
TRIED: If Form_sfrBoLDetail.Recordset.RecordCount > 0 And Not
IsNull([cboBillOfLadingID]) Then Exit Sub
TRIED: If Form_sfrBoLDetail.Recordset.RecordCount > 0 And
Me.cboBillOfLadingID < 0 Then Exit Sub
----- Balance of code----
Dim Msg, Style, Title, Response, MyString
Msg = "There are no lifts on this Bill of Lading, it will be deleted!
Is that what you want to do?"
Style = vbYesNo + vbQuestion + vbDefaultButton1
Title = "Delete"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
MyString = "Yes"
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE tblBillOfLading.bolBillOfLadingID FROM
tblBillOfLading WHERE (((tblBillOfLading.bolBillOfLadingID) =
[Forms]![frmBillOfLading]![txtBillOfLadingID]));"
DoCmd.RunSQL "UPDATE tblGetBillOfLadingID SET
tblGetBillOfLadingID.gbolBillOfLadingNumber = [gbolBillOfLadingNumber]-1,
tblGetBillOfLadingID.gbolBillOfLadingID = Val([gbolBillOfLadingID])-1 WHERE
(((tblGetBillOfLadingID.gbolBillOfLadingID)=[Forms]![frmBillOfLading]![cboBillOfLadingID])
AND
((tblGetBillOfLadingID.gbolCustomerID)=[Forms]![frmBillOfLading]![cboCustomerID]));"
DoCmd.SetWarnings True
Else
MyString = "No"
DoCmd.CancelEvent
End If
I have this on the Form_Unload event. What I want if both conditions are
true then ask the question. But if one or both of these conditions are true
then just close. I have tried the 3 condition below and none are working.
Can someone help me as to why it won't listen to me?
Thanks,
Gina Whipp
TRIED: If Form_sfrBoLDetail.Recordset.RecordCount > 0 Or Not
IsNull([cboBillOfLadingID]) Then Exit Sub
TRIED: If Form_sfrBoLDetail.Recordset.RecordCount > 0 And Not
IsNull([cboBillOfLadingID]) Then Exit Sub
TRIED: If Form_sfrBoLDetail.Recordset.RecordCount > 0 And
Me.cboBillOfLadingID < 0 Then Exit Sub
----- Balance of code----
Dim Msg, Style, Title, Response, MyString
Msg = "There are no lifts on this Bill of Lading, it will be deleted!
Is that what you want to do?"
Style = vbYesNo + vbQuestion + vbDefaultButton1
Title = "Delete"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
MyString = "Yes"
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE tblBillOfLading.bolBillOfLadingID FROM
tblBillOfLading WHERE (((tblBillOfLading.bolBillOfLadingID) =
[Forms]![frmBillOfLading]![txtBillOfLadingID]));"
DoCmd.RunSQL "UPDATE tblGetBillOfLadingID SET
tblGetBillOfLadingID.gbolBillOfLadingNumber = [gbolBillOfLadingNumber]-1,
tblGetBillOfLadingID.gbolBillOfLadingID = Val([gbolBillOfLadingID])-1 WHERE
(((tblGetBillOfLadingID.gbolBillOfLadingID)=[Forms]![frmBillOfLading]![cboBillOfLadingID])
AND
((tblGetBillOfLadingID.gbolCustomerID)=[Forms]![frmBillOfLading]![cboCustomerID]));"
DoCmd.SetWarnings True
Else
MyString = "No"
DoCmd.CancelEvent
End If