2 combo boxes in a form

A

Ana

Hi,

In a form I have a combo box (comboA) where I select a client (CLIENT_NAME)
and then with the following command, I display a report:



Dim stDocName As String

Dim strSQL As String



stDocName = "Client Report"

strSQL = "[CLIENT_ID] =" & Me![CLIENT_ID]

DoCmd.OpenReport stDocName, acViewPreview, WhereCondition:=strSQL





CLIENT_ID, CLIENT_NAME and CLIENT _DPT form part of the combo box.



I would like to add a second combo box (comboB) so that I can select
CLIENT_DPT. Unfortunately, the above command won't for comboB even though
both combo boxes have CLIENT_ID in common.





Howto fix it?

TIA

Ana



A2k -> SQLserver2k
 
G

Guest

Using the information posted:
CLIENT_ID, CLIENT_NAME and CLIENT _DPT form part of the combo box.
I am assuming that each is a column is ComboA and that CLIEND_ID is the
bound column for ComboA.
CLIENT_ID = Column(0)
CLIENT_NAME = Column(1)
CLIENT _DPT = Column(2)

So, If CLIENT_ID is the bound column:
strSQL = "[CLIENT_ID] =" & Me!ComboA & " AND [CLIENT_DPT] = '" _
& Me!ComboA.Column(2) & "'"

If it is not:
strSQL = "[CLIENT_ID] =" & Me!ComboA.Column(0) & " AND [CLIENT_DPT] = '" _
& Me!ComboA.Column(2) & "'"

Also notice I have coded this as if CLIENT_DPT is a text field. If it is a
numeric field remove the single quotes and the & "'" at the end of the
statement.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top