Same record - subform

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

Bonnie

Hi,
I'm still struggling with this. Please help! I am
opening a subfrom from the main form with this code (when
they key "Y"):

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

The problem is, it always saves to a new record - I want
the same record as the main Form. That's what I am
trying to do with the autonum filter. I am only using
one table - not relational. Tried it several different
ways and it doesn't work. Can you help me please?
 
Hi Bonnie

I assume from its name that [autonum] is a numeric autonumber field. Have
you tried:

DoCmd.OpenForm "codef", , , "[autonum]=" & Me!autonum
....?

Note that numeric values do not need to be surrounded by quotes.
 
Just went and tried it and it didn't work. I'm stumped.

-----Original Message-----
Hi Bonnie

I assume from its name that [autonum] is a numeric autonumber field. Have
you tried:

DoCmd.OpenForm "codef", , , "[autonum]=" & Me!autonum
....?

Note that numeric values do not need to be surrounded by quotes.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Hi,
I'm still struggling with this. Please help! I am
opening a subfrom from the main form with this code (when
they key "Y"):

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

The problem is, it always saves to a new record - I want
the same record as the main Form. That's what I am
trying to do with the autonum filter. I am only using
one table - not relational. Tried it several different
ways and it doesn't work. Can you help me please?


.
 
Are you sure that the codef form is not set as a Data Entry form? Look at
the Form's data properties.

This should work.

Dim StrCriteria As String, VarAuto As Long
VarAuto = Me.autonum
StrCriteria = "[autonum] = " & VarAuto
DoCmd.OpenForm "codef ", , , StrCriteria

If that doesn't work try opening it like this

DoCmd.OpenForm "codef "

If you still get a new record, then there must be some code in codef that
inserts a new record when the form is open. Look for code in the "On Open"
or "On Load" events.



Bonnie said:
Just went and tried it and it didn't work. I'm stumped.

-----Original Message-----
Hi Bonnie

I assume from its name that [autonum] is a numeric autonumber field. Have
you tried:

DoCmd.OpenForm "codef", , , "[autonum]=" & Me!autonum
....?

Note that numeric values do not need to be surrounded by quotes.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Hi,
I'm still struggling with this. Please help! I am
opening a subfrom from the main form with this code (when
they key "Y"):

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

The problem is, it always saves to a new record - I want
the same record as the main Form. That's what I am
trying to do with the autonum filter. I am only using
one table - not relational. Tried it several different
ways and it doesn't work. Can you help me please?


.
 
SUFFERING SUCCOTASH - your a genius. It was set to Data
Entry and when I changed that it works (even with my
original code)! Thank you very much. I'll remember you
in my will.
-----Original Message-----
Are you sure that the codef form is not set as a Data Entry form? Look at
the Form's data properties.

This should work.

Dim StrCriteria As String, VarAuto As Long
VarAuto = Me.autonum
StrCriteria = "[autonum] = " & VarAuto
DoCmd.OpenForm "codef ", , , StrCriteria

If that doesn't work try opening it like this

DoCmd.OpenForm "codef "

If you still get a new record, then there must be some code in codef that
inserts a new record when the form is open. Look for code in the "On Open"
or "On Load" events.



Just went and tried it and it didn't work. I'm stumped.

-----Original Message-----
Hi Bonnie

I assume from its name that [autonum] is a numeric autonumber field. Have
you tried:

DoCmd.OpenForm "codef", , , "[autonum]=" & Me!autonum
....?

Note that numeric values do not need to be surrounded
by
quotes.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

"Bonnie" <[email protected]> wrote
in
message
Hi,
I'm still struggling with this. Please help! I am
opening a subfrom from the main form with this code (when
they key "Y"):

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

The problem is, it always saves to a new record - I want
the same record as the main Form. That's what I am
trying to do with the autonum filter. I am only using
one table - not relational. Tried it several different
ways and it doesn't work. Can you help me please?



.


.
 
Back
Top