Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combo filter not working properly

Status
Not open for further replies.
Oct 4, 2002
2
CA
Hi,
Any help on this would be greatly appreciated.
I am opening a form based on 4 combo-box filters.
cmbAssignment
cmbStatus
cmbSource
cmbLeadNumber

In the query to open the form "Main Lead Form", i have put in the criteria section:
Like "*" & [Forms]![Switchboard].[cmbAssignment] & "*"
Like "*" & [Forms]![Switchboard].[cmbStatus] & "*"
Like "*" & [Forms]![Switchboard].[cmbSource] & "*"
Like "*" & [Forms]![Switchboard].[cmbLeadNumber] & "*"

In VBA, i have put this:
If Nz(cmbSource, "") = "" Then
cmbSource = "*"
End If
If Nz(cmbAssignment, "") = "" Then
cmbAssignment = "*"
End If
If Nz(cmbStatus, "") = "" Then
cmbStatus = "*"
End If
'Problem1: I can't put "*" -this is an autonumber/numeric field? Error if I put "*"
If Nz(cmbLeadNumber, "") = "" Then
cmbLeadNumber = ""
End If
stDocName = "Main Lead Form"
DoCmd.RunMacro "Minimize"
DoCmd.OpenForm stDocName, , , stLinkCriteria

If cmbSource = "*" Then
cmbSource = ""
End If
If cmbAssignment = "*" Then
cmbAssignment = ""
End If
If cmbStatus = "*" Then
cmbStatus = ""
End If
If cmbLeadNumber = "" Then
cmbLeadNumber = ""
End If

DoCmd.OpenForm stDocName, , , stLinkCriteria
BIG PROBLEM2:
And I don't know if it's related..but when I select LeadNumber 7 for example, the query will give me everything
with 7 in it, i.e. 17,170,1771, etc. It's like it's reading text.

So, am I using the wrong wildcard for the numeric field??
I'm not sure how simple/complicated the problem is..I'm learning as I go.

Thank you in advance!
 

If Nz(cmbSource, "") = "" Then
cmbSource = "*"
End If
If Nz(cmbAssignment, "") = "" Then
cmbAssignment = "*"
End If
If Nz(cmbStatus, "") = "" Then
cmbStatus = "*"
End If
'Problem1: I can't put "*" -this is an autonumber/numeric field? Error if I put "*"
-------------------------------------------
Set the ControlSource vs the RecordSource using SQL
When it is bound to a field and you enter "*" it tries
to change the value to "*" and obviously, if it is a
numeric field it will fail.
-------------------------------------------

If Nz(cmbLeadNumber, "") = "" Then
cmbLeadNumber = ""
End If
stDocName = "Main Lead Form"
DoCmd.RunMacro "Minimize"
DoCmd.OpenForm stDocName, , , stLinkCriteria

If cmbSource = "*" Then
cmbSource = ""
End If
If cmbAssignment = "*" Then
cmbAssignment = ""
End If
If cmbStatus = "*" Then
cmbStatus = ""
End If
If cmbLeadNumber = "" Then
cmbLeadNumber = ""
End If

DoCmd.OpenForm stDocName, , , stLinkCriteria -------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top