A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

passing value from subform



 
 
Thread Tools Display Modes
  #1  
Old December 20th, 2006, 05:05 PM posted to microsoft.public.access.forms
David#
external usenet poster
 
Posts: 15
Default passing value from subform

I have a Form “Developments” with a subform “Lots”. My “Lots” table has a
auto number key [LotID]. I want to display fi;tered “LotDetail” form based
on which lot I select on the lots subform AND be able to Add/Edit the lot
detail records. Problem: When I display my LotDetail records, the correct
records show but I have to manually enter the “LotID” in order to add
records. The “lotDetail” form is not picking up that lotID from the subform
“Lots” How do I pass this value? (I’m open the “LotDetail” with a macro
where a where condition LotID=forms!Lotsubform!LotID.
  #2  
Old December 20th, 2006, 06:19 PM posted to microsoft.public.access.forms
John Vinson
external usenet poster
 
Posts: 4,033
Default passing value from subform

On Wed, 20 Dec 2006 08:05:00 -0800, David#
wrote:

I have a Form Developments with a subform Lots. My Lots table has a
auto number key [LotID]. I want to display fi;tered LotDetail form based
on which lot I select on the lots subform AND be able to Add/Edit the lot
detail records. Problem: When I display my LotDetail records, the correct
records show but I have to manually enter the LotID in order to add
records. The lotDetail form is not picking up that lotID from the subform
Lots How do I pass this value? (Im open the LotDetail with a macro
where a where condition LotID=forms!Lotsubform!LotID.


YOu'll need to use VBA code rather than a Macro, I'd guess; have it
set the DefaultValue property of the LotDetail LotID control.
Something like

Private Sub cmdOpenLotDetail_Click()
DoCMd.OpenForm "lotDetail", WhereCondition:=Me.LotID, _
OpenArgs:=Me.LotID
End SUb

and in the Open event of lotDetail

Private Sub Form_Open(Cancel as Integer)
If Me.OpenArgs & "" "" Then ' did user pass an ID?
Me.txtLotID.DefaultValue = "'" & Me.OpenArgs & "'"
End If
End Sub

John W. Vinson[MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:32 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.