Hi, I want to conect two comobox to the wrong serch button. I want to choose two names after that date and then i'll check it out for it (1 Viewer)

jasm1243

New member
Local time
Today, 23:16
Joined
May 21, 2022
Messages
5
Hi, I want to conect two comobox to the wrong serch button. I want to choose two names after that date and then i'll check it out for it
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:16
Joined
May 7, 2009
Messages
19,246
even if you share your db, it is arabic and adding code will not work with your form with arabic characters.
 

jasm1243

New member
Local time
Today, 23:16
Joined
May 21, 2022
Messages
5
even if you share your db, it is arabic and adding code will not work with your form with arabic characters.

Dim strQuery As String
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"

strQuery = "qry_Inspections"

If Not IsNull(Me.cboWorker) Then
strWhere = strWhere & "([nawjory madaa] = """ & Me.cboWorker & """) AND "
End If

If Not IsNull(Me.txtFrom) Then
strWhere = strWhere & "([rekawtyhatnn] >= " & Format(Me.txtFrom, conJetDate) & ") AND "
End If

lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
With Me.qry_Inspections_subform
Filter = ""
FilterOn = False
End With
Else
roi = 8
strWhere = Left$(strWhere, lngLen)
Debug.Print strWhere
With Me.qry_Inspections_subform.Form
.Filter = strWhere
.FilterOn = True
End With
End If
End Sub

Private Sub namecp_AfterUpdate()
Dim strSQL As String
strSQL = "SELECT Table_info.i, tblManager.strManagerName " & _
"FROM tblManager " & _
"WHERE table_info.id__infoo= " & Me.namecp & _
" ORDER BY Table_infoo.nawycompanyy;"
Me.namecp.RowSource = strSQL
Me.namecp.Requery
End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:16
Joined
Sep 21, 2011
Messages
14,369
Put the sql into a string variable and Debug.Print it to show your errors.
You need to concatenate string literals with the variables, not just add it into the statement.

If you debug.print the sql, it will show, or should show you the error. if not you can post the ootput back here for someone to look at.

Also use the code tag icon to keep indentation. Hopefully you are using indentation?
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:16
Joined
Sep 21, 2011
Messages
14,369
Version is too late for me
1653159841626.png
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:16
Joined
Sep 21, 2011
Messages
14,369
Cross posting the same question is not going to help you, in fact it mght have the opposite effect.:mad:
 

jasm1243

New member
Local time
Today, 23:16
Joined
May 21, 2022
Messages
5
I want to make a search the way I've selected in the picture. I have a complete combox, but secondly, I don't know how to connect.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 15:16
Joined
Feb 28, 2001
Messages
27,242
Let me try to ask a question that might clear this up.

Is it your intent to do a search based on ALL of the non-blank boxes that have arrows leading to the search button?

Also, why are you calling it the "wrong" search button?

The usual way you do this is similar to what you showed us in post #3, where you build a WHERE clause based on those controls that are not blank. You build the string to include the SELECT and FROM clauses so that you pick up what you want from where you want it. But you build the WHERE clause to specify the things you wanted based on the controls.

So, ... you put an empty string and test each related control. If the control is not blank, you add an element to the WHERE clause like you were doing in post #3. You showed us four arrows leading to the SEARCH button. So you would build the WHERE clause to have elements like "WHERE DateTo <= #" & Me.tbDateFrom & "# AND " and so on.

You appear to have started down that path. Can you be more specific about what is causing the problem?
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:16
Joined
Sep 21, 2011
Messages
14,369
I have already said the dB is too late for my version of access.
Why are you pestering me in private conversations?:mad:

Any help I can give is always via forums, so others can see, plus avoid duplicating advice if you are asking others via pm.:unsure:
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:16
Joined
May 7, 2009
Messages
19,246
see your subform.
view the code also.
 

Attachments

  • my dat base.accdb
    1.1 MB · Views: 84

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:16
Joined
Feb 19, 2002
Messages
43,374
@jasm,
Welcome aboard.
I moved your question to one of the Access threads. You're new here and you picked a forum that is not used for questions so I moved it to Forms since the question was about controls on a form.
 

Users who are viewing this thread

Top Bottom