Solved

defining a field from a form in SQL

Posted on 2012-12-28
2
146 Views
Last Modified: 2013-01-02
I have a form, [EOS Ranking], which has a command button to call for another form.  I set the record based on the filter criteria [item_number]

I had to change my subform and it now it too  includes a field [item_number] as well so, where this string worked before, it no longer does.

DoCmd.OpenForm "sfrm_sales_xref_data", WhereCondition:="Item_Number = '" & [ITEM_NUMBER] & "'"

I think I need to define that [item_number] is coming from my primary form [EOS Ranking]

How would I rewrite my script?
0
Comment
Question by:MCaliebe
2 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 125 total points
ID: 38728523
Try:

DoCmd.OpenForm "sfrm_sales_xref_data", WhereCondition:="Item_Number = '" & Forms!theParentForm![ITEM_NUMBER] & "'"

Where theParentForm is the Main form containing sfrm_sales_xref_data subform.
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38728697
If this line of code is inside the subform, you could also use the Parent keyword to refer to the main form:
DoCmd.OpenForm "sfrm_sales_xref_data", WhereCondition:="Item_Number = '" & Parent.[ITEM_NUMBER] & "'"
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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 …

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now