View Single Post
  #2  
Old December 20th, 2006, 05: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? (I’m 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]