Solved

Access SQL - Referring to a "parent" form

Posted on 2014-04-16
5
430 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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 functions 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 Ac…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

735 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