Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox + Focus + Query

Status
Not open for further replies.

danvzla

Programmer
Jan 16, 2004
28
FI
HI.

I have a query where the result depends on different comboboxes that are going to have the values for the filters. When I run the query only uses the value of the combobox that GOT THE FOCUS. It is possible to have focus on 3 objects at the time? If not, how can I do force the query to see the values of the 3 comboboxes in order to use them for doing the filter (Combotex1 AND Combotext2 AND ComboText3)

Thanks!
Dan
 
It is not possible for more than one object to have focus simultaneously. However, the query can reference multiple controls from your form. The syntax will look like this: [forms]![FormName]![ControlName]
 
How are ya mndrlion . . . . .

You'll either have to use the [blue]Column Property[/blue] in your query, or use [blue]SQL in VBA[/blue] . . . . .

cal.gif
See Ya! . . . . . .
 


Mndrlion,

That is what I'm doing ([forms]![FormName]![ControlName]) also I tried with [forms]![FormName]![ControlName].text, but this only works when the focus is on the combobox you whant to use as a filter. If you need to refer to 2 comboboxes at the same time (AND) it doesn't work.

Thanks

Dan
 
Hi

How are you running the query, are you requerying after changes in the value of the combo boxes?

Maybe you could give us a clue and show your SQL and your code in the combo boxes

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
OK, let me see if I can explain this....

I got a form X with 4 comboboxes/textboxes (Combo8 (request), LogIDTxt (ID), cboStartDate (date), ComboMarketText(market)). The form also has a subform that is a table result of a query that takes the texts of the 4 comboboxes on form X for the filtering criteria.

The query is this:

SELECT LogDatafill_Table_AWS.[Tracking Number], LogDatafill_Table_AWS.Request, LogDatafill_Table_AWS.Date, LogDatafill_Table_AWS.Time, LogDatafill_Table_AWS.APPROVED, LogDatafill_Table_AWS.Tech, LogDatafill_Table_AWS.RNWE, LogDatafill_Table_AWS.Comment, LogDatafill_Table_AWS.Hyperlink, LogDatafill_Table_AWS.Sites
FROM LogDatafill_Table_AWS
WHERE (((Left([ID],5))=[Forms]![LogFileForm_AWS]![LogIDTxt].[Text])) OR (((LogDatafill_Table_AWS.Date)=[Forms]![LogFileForm_AWS]![cboStartDate])) OR (((LogDatafill_Table_AWS.Request)=[Forms]![LogFileForm_AWS]![Combo8]) AND ((LogDatafill_Table_AWS.Market)=[Forms]![LogFileForm_AWS]![ComboMarketText])) OR (((LogDatafill_Table_AWS.Request)=[Forms]![LogFileForm_AWS]![Combo8])) OR (((LogDatafill_Table_AWS.Market)=[Forms]![LogFileForm_AWS]![ComboMarketText]))
ORDER BY LogDatafill_Table_AWS.Date DESC , LogDatafill_Table_AWS.Time DESC , Left([ID],5);

Pressing "Search" button in form X the form will be refresh showing the result of the query using the criteria that were on the comboboxes at that moment.

When I put data only in one of the comboboxes (Combo8, LogIDTxt, cboStartDate, ComboMarketText) the filter is done OK, when I try to put data in 2, like all the info from one market received on date ##, it doesn't work (AND is not working).

I hope that you understand.

Thanks

Dan
 
Hi...

I found how to do it with VBA

Thanks a lot for your help

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top