Urgent! Help Please!!

N

Nick C

I have created an MSAccess 2000 form that allows users to print the last
record entered and add a new record. This is the code for the print button:

Private Sub cmdPrintCert_Click()
On Error GoTo ErrLast

DoCmd.RunCommand acCmdRecordsGoToLast

Dim stReportName As String
Dim stCriteria As String
stReportName = "rptCofC"
stCriteria = "[ID] = " & Me![ID] & ""
DoCmd.OpenReport stReportName, acPrint, , stCriteria

DoCmd.GoToRecord , , acNewRec

Exit Sub

ErrLast:
Select Case Err
Case 2046
'Command not available
MsgBox "You are already on the last record.", vbInformation, "Not
Available"
Case Else
MsgBox Err.Number & ":-" & vbCrLf & Err.Description

End Select

End Sub


The problem I am having is as follows: there are fields in the text and
combo boxes that need to be retained from the previous record since a lot of
the data entry is repetitive. I created an event procedure for the text
boxes that need to retain data from the last record entered as follows:

Private Sub Descr_AfterUpdate()
Me.ActiveControl.DefaultValue = "'" & Me.ActiveControl & "'"
End Sub


However, the Print button overrides this code and upon printing, the fields
are once again blank. I really need to get this to work; it would save our
users a LOT of time. Any help here would be GREATLY appreciated.


Thanks in advance,

Nick
 
J

John Spencer (MVP)

Why do you move to the Last record? Are you just trying to force the record to
be saved??

I would use

If Me.Dirty then Me.Dirty = False

to force the record to be save. Drop the Docmd.RunCommand acCmdRecordsGoToLast line.

That
 
N

Nick

Thanks to both of you for the help.

Nick C

John Spencer (MVP) said:
Why do you move to the Last record? Are you just trying to force the record to
be saved??

I would use

If Me.Dirty then Me.Dirty = False

to force the record to be save. Drop the Docmd.RunCommand acCmdRecordsGoToLast line.

That

Nick said:
I have created an MSAccess 2000 form that allows users to print the last
record entered and add a new record. This is the code for the print button:

Private Sub cmdPrintCert_Click()
On Error GoTo ErrLast

DoCmd.RunCommand acCmdRecordsGoToLast

Dim stReportName As String
Dim stCriteria As String
stReportName = "rptCofC"
stCriteria = "[ID] = " & Me![ID] & ""
DoCmd.OpenReport stReportName, acPrint, , stCriteria

DoCmd.GoToRecord , , acNewRec

Exit Sub

ErrLast:
Select Case Err
Case 2046
'Command not available
MsgBox "You are already on the last record.", vbInformation, "Not
Available"
Case Else
MsgBox Err.Number & ":-" & vbCrLf & Err.Description

End Select

End Sub

The problem I am having is as follows: there are fields in the text and
combo boxes that need to be retained from the previous record since a lot of
the data entry is repetitive. I created an event procedure for the text
boxes that need to retain data from the last record entered as follows:

Private Sub Descr_AfterUpdate()
Me.ActiveControl.DefaultValue = "'" & Me.ActiveControl & "'"
End Sub

However, the Print button overrides this code and upon printing, the fields
are once again blank. I really need to get this to work; it would save our
users a LOT of time. Any help here would be GREATLY appreciated.

Thanks in advance,

Nick
 

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