Selasa, 18 April 2017

Re: [MS_AccessPros] combo box filter criteria

 

David-

1) Unless you embed the value for Me.txtLocationID in SQL generated in code, you have to use the full Forms! Reference.  The SQL engine has no clue what Me is.

2) I would have to see your code to explain why using a variable didn't work.

3) Yes, but see the answer to question 2.

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 19, 2017, at 00:00, david.pratt@outlook.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

OK, so I did this and it works but it leads me to a couple of questions for the purpose of education. I made a text box on the form frmSampleGroupsAndUsers (this is the "called" form), and named it txtLocationID and assigned it the value Forms!frmConfigureSampleGroupsAndUsers!cboSelectSite.column(1).  For now I have left the control visible so I can see that it is working.

In the query criteria I first tried Me.txtLocationID and I got an empty query result.  I changed to "long Hand" and put Forms!frmSampleGroupsAndUsers.txtLocationID and it works fine.  question 1 is why would Me.txtLocationID not work?

Question 2 is why would the text box method work, but creating a variable in the event code not work.  I had already tried creating a variable lngLocationID, assigning the column(1) value to the variable, and using the variable in the query.  No joy there.

Question 3 is, could I have passed the value I needed with OpenArgs and used OpenArgs as the query criteria?

So much to learn...

__._,_.___

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 (5)

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