Senin, 17 April 2017

Re: [MS_AccessPros] combo box filter criteria

 

David-

This is one of the quirks in Access - you can't reference a control property or collection as a parameter.  (Column is a collection of the combo box and list box controls.). The workaround is to place a hidden text box on the form (Visible = No) and set its Control Source to: =[cboSelectSite].Column(1)

Then reference that control in your parameter.

John Viescas, author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Access Applications

On Apr 17, 2017, at 22:39, david.pratt@outlook.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

I have a simple form containing a text box txtSampleGroups and a combo cboUsers.  The form is called from another form, frmConfigureSampleGroupsAndUsers.  From the passing form I pass the SampleGoupID via OpenArgs. No problem. I am trying to filter the combo box based on the value of the second column of a combo on the passing form, cboSelectSite. So my criteria is Forms!frmConfigureSampleGroupsAndUsers!cboSelectSite.column(1).  I am trying to enter the criteria into the query design window and am having NO luck at all.  I get no records.  I have tried multiple different things.

Right now this is what my query SQL says (built from design view):

SELECT tbl010Users.UserID, [LastName] & ", " & [FirstName] AS UserName, tbl101Locations_Users.LocationID
FROM tbl010Users INNER JOIN tbl101Locations_Users ON tbl010Users.UserID = tbl101Locations_Users.UserID
WHERE (((tbl101Locations_Users.LocationID)=[Forms]![frmConfigureSampleGroupsAndUsers]![cboSelectSite].column(1)))
ORDER BY [LastName] & ", " & [FirstName];

I get no results from this query.  It works fine if I just manually enter an ID number such as 1 or 2, etc.  I have also tried creating a variable, lngLocationID, and setting the variable to cboSelectSite.column(1).  the variable gets properly updated, but when I put lngLocationID into the query criteria, again I get nothing.

This seems like it should be pretty simple but I cannot figure it out after hours of trying.



__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar