Thanks for the suggestion, but it hasn't worked. The only difference is that
when the second form opens from the command button I also get an error
message saying "Application-defined or object-defined error." I click on OK
on the error message and it goes away, then the second form opens and works
just as before. Still doesn't preserve the default value for the PK of the
first form for new records.
I'm afraid I don't know enough about VBA to follow your comment about
preferring to send and use OpenArgs on the form.
You would open the form with similar code:
Private Sub cmbOpenSubs_Click()
On Error GoTo Err_cmbOpenSubs_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmSubclients"
stLinkCriteria = "[PrmClntID]=" & Me![txtPrmCntID]
DoCmd.OpenForm stDocName, , , stLinkCriteria,,,Me!txtPrmCntID
Exit_cmbOpenSubs_Click:
Exit Sub
Err_cmbOpenSubs_Click:
MsgBox Err.Description
Resume Exit_cmbOpenSubs_Click
End Sub
Then in frmSubclients, use code in the On Open like:
If Len(Me.OpenArg & "") >0 Then
Me.txtPrmCntlID.DefaultValue = Me.OpenArgs
End If

Signature
Duane Hookom
MS Access MVP
> Thanks for the suggestion, but it hasn't worked. The only difference is
> that
[quoted text clipped - 8 lines]
> I'm afraid I don't know enough about VBA to follow your comment about
> preferring to send and use OpenArgs on the form.
dbnDavid - 28 Apr 2006 06:28 GMT
Your first bit of code is OK, but the second:
> Then in frmSubclients, use code in the On Open like:
>
> If Len(Me.OpenArg & "") >0 Then
> Me.txtPrmCntlID.DefaultValue = Me.OpenArgs
> End If
doesn't work. The error message I get is
"Compile error: Method or data member not found" and ".OpenArg" is
highlighted in the vba window.
Duane Hookom - 28 Apr 2006 12:35 GMT
You didn't fix my typo ;-)
If Len(Me.OpenArgs & "") >0 Then
Me.txtPrmCntlID.DefaultValue = Me.OpenArgs
End If

Signature
Duane Hookom
MS Access MVP
> Your first bit of code is OK, but the second:
>
[quoted text clipped - 7 lines]
> "Compile error: Method or data member not found" and ".OpenArg" is
> highlighted in the vba window.
dbnDavid - 28 Apr 2006 22:26 GMT
Thanks very much Duane.
Looking long and hard at your code (I'm on a steep learning curve here) I
did eventually figure that there might be a typo so I tried fixing it, only
to find that the debug then picked up other things (so at least I knew I'd
got it right fixing your typo!). I gave up for a while, then came back and
discovered, looking really hard at the screen, that I was introducing new
typos of my own. And now at last it's all working just as it should. So
that's good, and the extremely useful little lesson in coding made it a
double bonus!
> You didn't fix my typo ;-)
>
[quoted text clipped - 13 lines]
> > "Compile error: Method or data member not found" and ".OpenArg" is
> > highlighted in the vba window.
Duane Hookom - 29 Apr 2006 05:47 GMT
Glad to hear you got it working and learned about code.

Signature
Duane Hookom
MS Access MVP
> Thanks very much Duane.
>
[quoted text clipped - 25 lines]
>> > "Compile error: Method or data member not found" and ".OpenArg" is
>> > highlighted in the vba window.