Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Add a where clause to expression builder - Easy fix?

Posted on 2008-10-30
2
Medium Priority
?
1,024 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
[X]
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
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

718 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