[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Access SQL - Referring to a "parent" form

Posted on 2014-04-16
5
Medium Priority
?
458 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 600 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 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 1400 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

650 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