pop up subform - creates new record

  • Thread starter Thread starter Bonnie
  • Start date Start date
B

Bonnie

Hi,

I have one table - I key some of the data from one form -
pop up another form when there is a codefendant, and key
the codefendant info in the second for which closes
nicely and returns me to the first form on page down.
The problem is, when I look at my data it has created two
seperate records. I want it all in the same record. Any
ideas?

Your counsel is appreciated.
 
Bonnie said:
Hi,

I have one table - I key some of the data from one form -
pop up another form when there is a codefendant, and key
the codefendant info in the second for which closes
nicely and returns me to the first form on page down.
The problem is, when I look at my data it has created two
seperate records. I want it all in the same record. Any
ideas?

Are both forms bound to the same tables? Sounds like your table design is
incorrect. Please explain how they are set up and how they relate to the
forms being used.
 
Write code to save the data on form one before opening form 2.
Then make sure that you have the primary key as a field on both forms. Next
pass the value of primary key in openargs variable of the open form
statement.
Second forms on open event needs to set the openargs as the filter for the
primary key field.
 
I see what you mean. I've set up a primary key. Would
you mind giving me a code example of saving the record
and passing the autonum to the second form?

Thanks
 
How does this look?

Private Sub Text107_Exit(Cancel As Integer)
Dim VarAuto As Variant
VarAuto = Tables!Liens!Autonum
If Me![Text107] = "Y" Then
.Update
DoCmd.OpenForm "codef", , , "Autonum = VarAuto"
End If
End Sub

When I exit this field Text107 (which just has a Y if
there is a codefendant) it opens the codef form.

Thanks.
 
I'm still having trouble. I have this now:

Private Sub Text107_Exit(Cancel As Integer)
Dim VarAuto As Variant
DoCmd.RunMacro "Macro13"
VarAuto = Me![autonum]
If Me![Text107] = "Y" Then
DoCmd.OpenForm "codef", , , "Autonum = '" & Forms!
Liens!autonum & "'"
End If
DoCmd.RunMacro "Macro13"
End Sub

It isn't working. I still get a new AutoNumber when I
start typing in the second form. Please help!

Thanks.
 
Back
Top