Using Multiple Criteria's when opening a Form

T

TwinDad

Hello All,

I have a Form that I need to open based on either On Criteria or another. I
created a "View Detail" Button Using the wizard, but it only opens it by
Customer Number.

My table holds both existing customers (They have Customer_Numbers) and
patrons that call in (They do not have Customer_Number). I can open the ones
with customer numbers but when i try to open the one without a
Customer_Number I get a Blank Screen. In the Properties it shows;

Filter: [Customer_Number]='' (These are 2 Single Quotes)

I Placed have this "If Statement" in the Event procedure.

I would just use the If Statement if it wasn't for the fact that there are
Customers with the Same name in the Cus

Private Sub Command11_Click()
On Error GoTo Err_Command11_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stLinkCriteria2 As String


stDocName = "frmAllCallsCustomerAndNon_Detail"

If [Customer_Number] = Null Then
stLinkCriteria = "[CompName]=" & "'" & Me![CompName] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
stLinkCriteria2 = "[Customer_Number]=" & "'" & Me![Customer_Number]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria2
End If

Exit_Command11_Click:
Exit Sub

Err_Command11_Click:
MsgBox Err.Description
Resume Exit_Command11_Click

End Sub
 
D

Douglas J. Steele

You cannot use the = sign in conjunction with Null values.

Change

If [Customer_Number] = Null Then

to

If IsNull([Customer_Number]) = True Then
 
T

TwinDad

Worked like a charm.

Thank you

Douglas J. Steele said:
You cannot use the = sign in conjunction with Null values.

Change

If [Customer_Number] = Null Then

to

If IsNull([Customer_Number]) = True Then


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


TwinDad said:
Hello All,

I have a Form that I need to open based on either On Criteria or another.
I
created a "View Detail" Button Using the wizard, but it only opens it by
Customer Number.

My table holds both existing customers (They have Customer_Numbers) and
patrons that call in (They do not have Customer_Number). I can open the
ones
with customer numbers but when i try to open the one without a
Customer_Number I get a Blank Screen. In the Properties it shows;

Filter: [Customer_Number]='' (These are 2 Single Quotes)

I Placed have this "If Statement" in the Event procedure.

I would just use the If Statement if it wasn't for the fact that there are
Customers with the Same name in the Cus

Private Sub Command11_Click()
On Error GoTo Err_Command11_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stLinkCriteria2 As String


stDocName = "frmAllCallsCustomerAndNon_Detail"

If [Customer_Number] = Null Then
stLinkCriteria = "[CompName]=" & "'" & Me![CompName] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
stLinkCriteria2 = "[Customer_Number]=" & "'" & Me![Customer_Number]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria2
End If

Exit_Command11_Click:
Exit Sub

Err_Command11_Click:
MsgBox Err.Description
Resume Exit_Command11_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top