open a form based on multiple comboboxes with some null values (1 Viewer)

t0n3l3s

New member
Local time
Today, 15:18
Joined
Jun 7, 2011
Messages
6
Ok, i'm tired of many hours searching thread by thread, i don't find it... i need some help, if anyone can help me in here i would apreciate.. i have a basic database and i'm applying some code to some things and this is the final thing! i want to do a personalized search.

One form with more than one combobox, i want that when i press "Search" it opens another form to show the results of the selected comboboxes but here is the thing! i want that even the comboboxes that are left empty don't affect the search.

I'm able to do only if i select values....

here is the code:

Code:
Private Sub search_Click()
On Error GoTo Err_search_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frm_personalized_query_search"
    
    stLinkCriteria = "[rank]= " & Me![rank] & " And [class]=" & Me![class] (and some more)

    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_search_Click:
    Exit Sub

Err_search_Click:
    'msgbox Err.Description
    Resume Exit_search_Click
    
End Sub

Can anyone help me? Thank you.
 

t0n3l3s

New member
Local time
Today, 15:18
Joined
Jun 7, 2011
Messages
6
thank you very much i'll try and keep you posted!
 

t0n3l3s

New member
Local time
Today, 15:18
Joined
Jun 7, 2011
Messages
6
I'm not getting... this is very simple but i don't know what is missing here, i don't understand much but i'm trying and learning, this example is very good but it's for the same form, i want to open a new form showing the filter: this is the code that i was trying to adapt:

Code:
Private Sub cmd_search_Click()

    Dim strWhere As String
    Dim lngLen As Long

    If Not IsNull(Me.[rank]) Then
        strWhere = strWhere & "([rank]= " & [Forms]![frm_personalized_query]![rank] & ") And "
    End If
    
    If Not IsNull(Me.[class]) Then
        strWhere = strWhere & "([class]= " & [Forms]![frm_personalized_query]![class] & ")"
    End If
    
    lngLen = Len(strWhere) - 1
    
    If lngLen <= 0 Then
        msgbox "None option selected!"
        Me.rank.SetFocus
        Me.rank.Dropdown
    Else
        strWhere = Left$(strWhere, lngLen)
        DoCmd.OpenForm "frm_personalized_query", acNormal, strWhere
        Me.Filter = strWhere
        Me.FilterOn = True
    End If
    
End Sub
 
Last edited:

t0n3l3s

New member
Local time
Today, 15:18
Joined
Jun 7, 2011
Messages
6
i would really apreciate a little help here if anyone could :)
 

jdraw

Super Moderator
Staff member
Local time
Today, 10:18
Joined
Jan 23, 2006
Messages
15,414
Do you have a form to go along with this code?
Do you have a button called cmd_search?

Do you have experience with vba?
Do you know what a Debug.print is?

What is the name of the New form?

Please describe exactly what you want to do.
 

t0n3l3s

New member
Local time
Today, 15:18
Joined
Jun 7, 2011
Messages
6
Do you have a form to go along with this code?
Yes, i have a search form and a results form, the search form have the comboboxes and the search button. the results form is to be opened when i press the "search" button and show the results of the search form.

Do you have a button called cmd_search?
yes that is the button to make the results form open based on combobox values.

Do you have experience with vba?
not much, only basic things.

Do you know what a Debug.print is?
nop i don't know what a Debug.print is.

What is the name of the New form?
search form with comboboxes = frm_consulta_personalizada (simple form)
results based on comboboxes = frm_listagem_personalizada (continuous form)

Please describe exactly what you want to do.

I want to select values from 10 comboboxes and press "Search", when i press search it will open another form with the results chosen in the comboboxes even if they are empty, i want it to ignore the empty. Is it possible to help me? Was i clear?

Thank you very much
 

Users who are viewing this thread

Top Bottom