Sorry for the confusion. I'm somewhat new at this and my terminology is not
correct. I have a subform (which is working fine). From the subform I want
to open an existing form and add a new record to that form.
I guess that is what I'm trying to do. I'm opening a form in its own right
from a subform. I want clientid passed from the subfrom to the newform.
I'm still not completely clear on what you're doing and why.
You have a main form, FormA. On that form you have a subform, FormB.
Somewhere on FormB (or maybe it's on FormA??) you have a control, let's
speculate that it's called cboClientID, bound to the ClientID field.
You want to click a button on the subform B and have a third form, FormC, pop
up - and you want to "pass" the ClientID to it.
What is Form C going to do with that client ID? Do you want it to open to that
client's existing record? If so, use the WhereCondition argument of the
OpenForm method:
DoCmd.OpenForm "FormC", WhereCondition:="[ClientID] = " & Me.cboClientID
Or do you want FormC to create a new record adding ClientID? If so, use the
OpenArgs argument of the OpenForm method to pass the value of the clientID,
and then put code in FormC's Open event to set the DefaultValue property of a
control:
DoCmd.OpenForm "FormC", OpenArgs:= Me.cboClientID
....
Private Function Form_Open(Cancel as Integer)
If Me.OpenArgs & "" <> "" Then ' was an ID passed?
Me.cboClientID.DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)
End If
End Sub
John W. Vinson [MVP]