[Help needed] Searching data using combo box on MS Access 2007

tarrozar

New member
Local time
Tomorrow, 03:45
Joined
Sep 1, 2014
Messages
4
Good day.

I am new to MS Access database and I am currently developing a DB with search function in a form for an inventory purpose, I have followed some VB codes from the web.

Here is my issue; when I try to search using the configured combo box in the form it gives me these sets of values, here is the screenie //oi57.tinypic.com/24fxwzk.jpg (just add the http: before the forward slashes as the site wont allow me to post images or links yet)

Row source for data: "-1";"Office 2010";0;"Office 2007";1;"Visio 2010";2;"Visio 2007";3;"Project 2010";4;"Project 2007"

and here is the VB code:

Code:
 If Not IsNull(Me.compName2) Then
        strWhere = strWhere & "([Computer Name] Like ""*" & Me.compName2 & "*"") AND "
    End If
    
    
    If Not IsNull(Me.cUser2) Then
        strWhere = strWhere & "([Current User] Like ""*" & Me.cUser2 & "*"") AND "
    End If
    
    If Me.cboSoftware2 = -1 Then
        strWhere = strWhere & "([Office 2010] = True) AND "
        End If
    If Me.cboSoftware2 = 0 Then
        strWhere = strWhere & "([Office 2007] = True) AND "
        End If
    If Me.cboSoftware2 = 1 Then
        strWhere = strWhere & "([Visio 2010] = True) AND "
    End If
    If Me.cboSoftware2 = 2 Then
        
        strWhere = strWhere & "([Visio 2007] = True) AND "
    End If
    
    If Me.cboSoftware2 = 3 Then
        strWhere = strWhere & "([Project 2010] = True) AND "
    End If
    
    If Me.cboSoftware2 = 4 Then
        strWhere = strWhere & "([Project 2007] = True) AND "
    End If

Can anyone tell me where did I go wrong? I just wanted to eliminate the numbers and replace them with the actual values as name. ex. "-1";"Office 2010" instead of (-1) doing the search, it should be the value "Office 2010"

Thanks in advance
 
Last edited:
Why not set up the Combo Box to one column? Then you can search by the name.
 
I have tried that, but when I try to search by name it gives me the "no criteria" message
 
I tried changing the code of instead from this {If Me.cboSoftware2 = -1 Then
strWhere = strWhere & "([Office 2010] = True) AND "
End If}

to this
{ If Me.cboSoftware2 = Office2010 Then
strWhere = strWhere & "([Office 2010] = True) AND "
End If}

but still it gives me the "no criteria" message
 
Two things...

1. Did you change the Combo Box to only have one Column?
2. The name in the Combo Box and the name in the strWhere line need to match, exactly. You can't have one with a space and the other without.
 

Users who are viewing this thread

Back
Top Bottom