is my if statement correct or not ???

doran_doran

Registered User.
Local time
Yesterday, 20:29
Joined
Aug 15, 2002
Messages
349
Ok, I have following. I have a form called "frmGroups" and there is a button called "cmdOpenInvoice". There is field in the frmGroups called cmdBillingStructure. If this field populated with "Group Not Billed" and if someone tries to click on Invoice I would like to pop a msg "are you sure you want to create an invoice", if end user click no it should come back to the same record in frmGroups. Now, if the field populated with "group billed" then there should be no msg and it should open "frmOrderbyCustomer"

Regards / Dianna Jamil Goldburg

Here is my code
=========================================================
Private Sub cmdOpenInvoice_Click()

On Error GoTo Err_OpenInvoice_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Const Message7 = "This group is set to Group Not Billed, Are you Sure you want to create an Invoice."

If Me.cboBillingStructure.Value = "Group Not Billed" And MsgBox(Message7, vbQuestion + vbYesNo) = vbYes Then
DoCmd.OpenForm "frmOrdersByCustomer", , , "[GA_Record_ID_2]='" & [GA_Record_ID_2] & "'"
Else
Me.Visible = True
End If

Me.Visible = False

Exit_OpenInvoice_Click:
Exit Sub

Err_OpenInvoice_Click:
MsgBox Err.Description
Resume Exit_OpenInvoice_Click
End Sub
==========================================================
 
I think you are looking for something more like this...

Code:
Private Sub cmdOpenInvoice_Click()

On Error GoTo Err_OpenInvoice_Click

If Me.cboBillingStructure <> "Group Not Billed" Then
DoCmd.OpenForm "frmOrdersByCustomer", , , "[GA_Record_ID_2]='" & [GA_Record_ID_2] & "'"
Else
[INDENT]If msgbox("This group is set to Group Not Billed, Are you Sure you want to create an Invoice.",vbyesno,"Invoice Alert") = vbyes Then
DoCmd.OpenForm "frmOrdersByCustomer", , , "[GA_Record_ID_2]='" & [GA_Record_ID_2] & "'"
Else
End if[/INDENT]
End if

Exit_OpenInvoice_Click:
Exit Sub

Err_OpenInvoice_Click:
MsgBox Err.Description
Resume Exit_OpenInvoice_Click
End Sub
 
Thanks for the prompt respond.

Thanks for the prompt respond. It works. Except for the fact the form "frmOrdersbyCustomer" is behind the frmGroups and I can't see it. Originally I was hiding the frmGroups.

Thanks a Billion for the prompt help.

Appreciated (Dianna Goldsberg)



jfgambit said:
I think you are looking for something more like this...

Code:
Private Sub cmdOpenInvoice_Click()

On Error GoTo Err_OpenInvoice_Click

If Me.cboBillingStructure <> "Group Not Billed" Then
DoCmd.OpenForm "frmOrdersByCustomer", , , "[GA_Record_ID_2]='" & [GA_Record_ID_2] & "'"
Else
[INDENT]If msgbox("This group is set to Group Not Billed, Are you Sure you want to create an Invoice.",vbyesno,"Invoice Alert") = vbyes Then
DoCmd.OpenForm "frmOrdersByCustomer", , , "[GA_Record_ID_2]='" & [GA_Record_ID_2] & "'"
Else
End if[/INDENT]
End if

Exit_OpenInvoice_Click:
Exit Sub

Err_OpenInvoice_Click:
MsgBox Err.Description
Resume Exit_OpenInvoice_Click
End Sub
 

Users who are viewing this thread

Back
Top Bottom