Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > Access Forms Coding > Adding "all" to...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 41551 of 43413
Post > Topic >>

Adding "all" to combo box isn't working

by =?Utf-8?B?TnVrZUVuZzg1?= <NukeEng85@[EMAIL PROTECTED] > Aug 7, 2008 at 12:05 PM

so I have two combo boxes in a form and I need to be able to look up data 
with either one or both, meaning i need one to have an "all" option (or
just 
be null).  I tried putting this in the rowsource: 

SELECT DISTINCT [SNM Data].[SNM Type] FROM [SNM Data] UNION Select Null as

AllChoice, "(All)" as Bogus From [SNM Data]
ORDER BY [SNM Data].[SNM Type];

and it gave me an error message that says: "The number of columns in the
two 
selected tables or queries of a union query do not match."

I also tried changing the criteria for the field that is being filtered in

the query to this:

Forms!NameOfForm!NameOfCombo Or (Forms!NameOfForm!NameOfCombo = "any")
 
Another problem I'm having is that I have a command button that is
supposed 
to use the values selected in the combo box to filter data from the table 
into a subform (basically filtering and locating records) I am using the 
below code, and for some reason if I exit the form and pull it back up the

button stops working unless I first right click the form, select "Filter
by 
form" and then "apply filter/sort"  I want other people at my work to just
be 
able to pull this up and find what they need via the combo boxes, so I
really 
need it to work automatically.

Option Compare Database
Option Explicit



Private Sub Command44_Click()
    Dim strWhere As String                  'The criteria string.
    Dim lngLen As Long
    
    If Not IsNull(Me.Combo22) Then
         strWhere = strWhere & "([SNM TYPE] = """ & Me.Combo22 & """) AND
"
     End If
  

    If Not IsNull(Me.Combo24) Then
            strWhere = strWhere & "([ICA] = """ & Me.Combo24 & """) AND "
        End If
        
    lngLen = Len(strWhere) - 5
    If lngLen <= 0 Then
        MsgBox "No criteria", vbInformation, "Nothing to do."
    Else
        strWhere = Left$(strWhere, lngLen)
    Debug.Print strWhere


    Me.Filter = strWhere
    Me.FilterOn = True
    End If
End Sub
 




 4 Posts in Topic:
Adding "all" to combo box isn't working
=?Utf-8?B?TnVrZUVuZzg1?=   2008-08-07 12:05:00 
RE: Adding "all" to combo box isn't working
=?Utf-8?B?S0FSTCBERVdFWQ=  2008-08-07 14:02:01 
RE: Adding "all" to combo box isn't working
=?Utf-8?B?TnVrZUVuZzg1?=   2008-08-08 04:31:00 
RE: Adding "all" to combo box isn't working
=?Utf-8?B?S0FSTCBERVdFWQ=  2008-08-08 07:22:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 21:23:34 CST 2008.