Getting New Record To Load

G

Guest

With the Code below I'm trying to get a newly entered pt on the frmNewPt form
to be loaded on my form frmPtDemographicNew when the cboNewPtLoad button is
clicked. The frmPtDemographicNew form loads but doesn't go to the newly added
pt.

Any help would be greatly appreciated. Thanks, Rob

Private Sub cboNewPtLoad_Click()

Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Save
stDocName = "frmPtDemographicNew"

stLinkCriteria = "[MRN]=" & Me![MRN]

DoCmd.OpenForm stDocName, , , stLinkCriteria



End Sub
 
S

Steve Schapel

Rob,

DoCmd.Save means to save a design change to the form, and is unrelated
to the data. Instead, I think you need:
DoCmd.RunCommand acCmdSaveRecord
 
M

Marshall Barton

RobUCSD said:
With the Code below I'm trying to get a newly entered pt on the frmNewPt form
to be loaded on my form frmPtDemographicNew when the cboNewPtLoad button is
clicked. The frmPtDemographicNew form loads but doesn't go to the newly added
pt.

Any help would be greatly appreciated. Thanks, Rob

Private Sub cboNewPtLoad_Click()

Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Save
stDocName = "frmPtDemographicNew"

stLinkCriteria = "[MRN]=" & Me![MRN]

DoCmd.OpenForm stDocName, , , stLinkCriteria


Are you sure the new record was saved before opening the
other form? If not, then add a line at the top of the Click
event:
If Me.Dirty Then Me.Dirty = False
 
G

Guest

I made the suggested change and it works perfectly. Thanks

Steve Schapel said:
Rob,

DoCmd.Save means to save a design change to the form, and is unrelated
to the data. Instead, I think you need:
DoCmd.RunCommand acCmdSaveRecord

--
Steve Schapel, Microsoft Access MVP
With the Code below I'm trying to get a newly entered pt on the frmNewPt form
to be loaded on my form frmPtDemographicNew when the cboNewPtLoad button is
clicked. The frmPtDemographicNew form loads but doesn't go to the newly added
pt.

Any help would be greatly appreciated. Thanks, Rob

Private Sub cboNewPtLoad_Click()

Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Save
stDocName = "frmPtDemographicNew"

stLinkCriteria = "[MRN]=" & Me![MRN]

DoCmd.OpenForm stDocName, , , stLinkCriteria



End Sub
 

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