Solved Open a form to a specific record with 2 where conditions (1 Viewer)

RussPhi

New member
Local time
Today, 15:12
Joined
Jan 3, 2020
Messages
12
I have a customer form with 2 buttons "new orders" and "open orders"
I want the "open orders" btn to open only if the customer has and active order " is paid" is not checked
if the button "open orders" is pressed and there is not an open order I want a msgbox to display "customer does not have an open order"
my code still opens the order even if the "is paid" is checked.
any help would help

Private Sub OpenOrderBtn_Click()

DoCmd.OpenForm "OrderF", , , "[CustomerID]=" & [CustomerID]
If IsPaid = True Then
MsgBox "Customer does not have an open order"
End If


End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:12
Joined
Oct 29, 2018
Messages
21,521
Several ways to do that. Here's one.
Code:
If DCount("*","OrdersTableName","[Is Paid] = False AND CustomerID=" & Nz(Me.CustomerID,0)) = 0 Then
    MsgBox "Customer does not have an open order"
Else
    DoCmd.OpenForm "OrderF", , , "[Is Paid]=False AND CustomerID=" & Nz(Me.CustomerID,0)
End If
 

RussPhi

New member
Local time
Today, 15:12
Joined
Jan 3, 2020
Messages
12
awsome works like a charm thanks
 

Users who are viewing this thread

Top Bottom