Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Add a where clause to expression builder - Easy fix?

Posted on 2008-10-30
2
950 Views
Last Modified: 2013-11-28
Hello,

This should be a quick fix - but access is driving me nuts.  

In the simplest of terms: I have a two tables, A and B.  When a user clicks a particular field in table A, they are passed through to table B.  Table B contains a field called "NameField" which relates to a username.  The ID of this user is also passed to table B, and this appears in the NameField.

What I want to do, is run an epxression within the NameField similar to:

NameField = select username from users where userID = tableB.NameField....

Easy right?  I've tried creating macros, expressions, yadda yadda, and nothing.  This baffles me as it is the corner-stone of all forms: passing ID's and then looking up the rest of the info based on the ID.
 
0
Comment
Question by:south_paw
2 Comments
 
LVL 6

Expert Comment

by:carazuul
ID: 22846401
Hi south paw,
When you run the OpenForm action from Form A you can include a where clause to filter the results of the new form. In your case, adding a NameField = [Selected Name]. The code below shows an example of this.
Regards,
carazuul

Private Sub OpenNewFormButton_Click()
    
    Dim strForm As String, strFilter As String
    
    strForm = "FormB"
    strFilter = "NameField = '[userID]'"
    
    DoCmd.OpenForm strForm, , , strFilter
    
End Sub

Open in new window

0
 

Accepted Solution

by:
south_paw earned 0 total points
ID: 22846719
Hi,

Thanks but I need to do it for the particular field only.  I am already filtering data using something similar to the above, but table "users" is not the same thing as TableB.

Hope that helps.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question