Solved

Access SQL - Referring to a "parent" form

Posted on 2014-04-16
5
433 Views
Last Modified: 2014-04-16
Greetings!

See the very last "where" clause in my snippet.

The form will be called from one of two forms (either Job1 or Job2).

You will note that "Job1" is hardcoded into the "where" clause.

How do I change the "where" to simply refer to the parent form.....something like;
=forms!Parent![CustomerID]      (which does not work, of course).

SELECT tblCustomers.CustomerName, tblCustomers.CustomerID, [add1] & ", " & [add2] & ", " & [add3] & "," & [postcode] AS FullAddress, tblCustomers.GeneralComments, tblCustomers.EngineerComments, tblCustomers.RecommendedWorks, tblCustomers.CalloutCharge, tblCustomers.EngineersWorksCompleted
FROM tblCustomers
WHERE (((tblCustomers.CustomerID)=[forms]![job1]![CustomerID]));

Open in new window

0
Comment
Question by:Patrick O'Dea
[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
  • 2
5 Comments
 
LVL 35

Assisted Solution

by:Bembi
Bembi earned 150 total points
ID: 40005034
What is just to create a global variable and store the CustomerID there before you call the second form. This way you refer to the variable, not to the form.
0
 

Author Comment

by:Patrick O'Dea
ID: 40005140
Bembi,

Sounds like a good solution.  I created a global variable "CustomerCurrent".

But how to I refer the the global variable in the sql??
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 350 total points
ID: 40005186
If the code is in the form, it's:

 Me.Parent![<controlName>]

Jim.
0
 
LVL 35

Expert Comment

by:Bembi
ID: 40005194
WHERE tblCustomers.CustomerID= myVariableName

or if your SQL statement is text...

"..... WHERE tblCustomers.CustomerID = " & myVariableName
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 40005249
Thanks again Jim.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

738 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