On Click Procedure

  • Thread starter ladybug via AccessMonster.com
  • Start date
L

ladybug via AccessMonster.com

I have a command button on a subform that opens another form. The On Click
Event has this procedure:
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSection1PhysInfo"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

The "ID" is not populating on the second form. However, if I close the main
form and then open it and click the button the ID appears. Can someone help
me get the ID to populate the first time the button is clicked? Thanks!
 
D

Dale Fye

ladybug,

My first thought is that the record in you subform, to which Me![ID] refers
is probably a new record, and has not yet been saved. Try inserting the
following line just before the stLinkCriteria line:

me.dirty = false

Let us know if that has the desired effect.

Dale
 
L

ladybug via AccessMonster.com

I tried, it but no luck
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSection1PhysInfo"
Me.Dirty = False
stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria


Dale said:
ladybug,

My first thought is that the record in you subform, to which Me![ID] refers
is probably a new record, and has not yet been saved. Try inserting the
following line just before the stLinkCriteria line:

me.dirty = false

Let us know if that has the desired effect.

Dale
I have a command button on a subform that opens another form. The On Click
Event has this procedure:
[quoted text clipped - 9 lines]
form and then open it and click the button the ID appears. Can someone help
me get the ID to populate the first time the button is clicked? Thanks!
 
K

Klatuu

As Dale said, if this is a new record in the first form, it will not yet be
in the table, so the form you open will not find it. I don't know where you
put the code he suggested, but it should be like this:

Dim stDocName As String
Dim stLinkCriteria As String

If Me.Dirty Then
Me.Dirty = False
End If
stDocName = "frmSection1PhysInfo"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

--
Dave Hargis, Microsoft Access MVP


ladybug via AccessMonster.com said:
I tried, it but no luck
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSection1PhysInfo"
Me.Dirty = False
stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria


Dale said:
ladybug,

My first thought is that the record in you subform, to which Me![ID] refers
is probably a new record, and has not yet been saved. Try inserting the
following line just before the stLinkCriteria line:

me.dirty = false

Let us know if that has the desired effect.

Dale
I have a command button on a subform that opens another form. The On Click
Event has this procedure:
[quoted text clipped - 9 lines]
form and then open it and click the button the ID appears. Can someone help
me get the ID to populate the first time the button is clicked? Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top