May 26th, 2003, 03:58 PM
Join Date: May 2003
Location: North Idaho
Time spent in forums: < 1 sec
Reputation Power: 0
How do I open a new record in a sub form?
Hi, I have this code I am using in one form to open a "sub" form in MS access 2002.
It calls the ID (LngFamilyID) and if the the sub form has that ID it opens it.
My problem is when the sub form does not have that paticular ID it opens the first record.
How do I make it so IF there is no ID matching THEN go to the end of the record set, make a new record AND put the ID from the originating form in to the ID of the new record I just created.
Clear as mud?
Any way, here is my code I am using to open it right now.
AdoptFam is the name of the Check Box
Private Sub Command116_Click()
If AdoptFam = True Then
DoCmd.OpenForm "FrmAdoptF", acNormal, , , , , Me!LngFamilyID.Value
'And the code for the ID of the sub form...
Private Sub Form_Open(Cancel As Integer)
Dim strFamID As String
If Not IsNull(Forms!FrmAdoptF.OpenArgs) Then
strFamID = Forms!FrmAdoptF.OpenArgs
If Len(strFamID) > 0 Then
DoCmd.FindRecord strFamID, , True, , True, , True
Thanks a lot, Jacob