C
Colin Foster
Hi There,
I have a database with the following code attached to the OnClick event of a
button. The idea is when a Job has been created from a quotation, then this
will report all of the relevant details of the job.
Private Sub PrintJobSheet_Click()
Dim strRecordSource As String, strFormFilter As String
Dim stDocName As String
Dim strfilter As String
On Error GoTo Err_PrintJobSheet_Click
Me.Dirty = False
DoEvents
stDocName = "RptJobSheet"
strfilter = "jobno = " & Me.JobNo.Value
' Store the current recordsource and filter strings
strRecordSource = Me.RecordSource
strFormFilter = Me.Filter
' Freeze screen so that the data do not appear to change
DoCmd.Echo False
' Remove the current recordsource so that the report can use it
Me.RecordSource = ""
DoCmd.OpenReport stDocName, acPreview, , strfilter
Exit_PrintJobSheet_Click:
' Restore the recordsource to what it was
Me.RecordSource = strRecordSource
' Restore the filter to what it was
Me.Filter = strFormFilter
' Turn filter back on
Me.FilterOn = True
' Return to the record that was active when the button was clicked
Me.RecordsetClone.FindFirst strfilter
Me.Bookmark = Me.RecordsetClone.Bookmark
' Unfreeze the screen
DoCmd.Echo True
Exit Sub
The code was originally provided to me from one of the Access Newsgroups a
couple of years ago & seemed to work perfectly. However, now that I've
started to use this button more, I'm finding that when I click the button I
get an error dialog of "No Current Record". When I click the OK button on
this dialog, I then get another error dialog of "No Current Record" that
continues to loop in the same way until I get fed up & press CTRL+Break!
Going into the VBA coding, when I'm in DeBug mode, I've also noticed that
when I hover my mouse over the line of coding line...
Me.Bookmark = Me.RecordsetClone.Bookmark,
then I have a (not sure of technical term, but it's like ControlTip Text)
of Me.Bookmark = <No Current Record.> which is obviously what's causing the
issue.
Interestingly, some jobs print out ok, it's only when I'm creating a new job
that the issue arises. I have a button on my form to save the job, & that
appears to work. I've even gone back to the version that I had before
putting through these mods & realised that that isn't working, either (so
I've satisfied myself that it's not something that I've done on this Mod!
I'm using Access XP (in Access 2000 mode) to write the database (but also
have Access 2000 & 2003 installed) & th epc that's using the database is on
Access 2000. The database is also slpit between front & back ends.
Hope there's enough there for you guys to work on.
Regards
Colin Foster
I have a database with the following code attached to the OnClick event of a
button. The idea is when a Job has been created from a quotation, then this
will report all of the relevant details of the job.
Private Sub PrintJobSheet_Click()
Dim strRecordSource As String, strFormFilter As String
Dim stDocName As String
Dim strfilter As String
On Error GoTo Err_PrintJobSheet_Click
Me.Dirty = False
DoEvents
stDocName = "RptJobSheet"
strfilter = "jobno = " & Me.JobNo.Value
' Store the current recordsource and filter strings
strRecordSource = Me.RecordSource
strFormFilter = Me.Filter
' Freeze screen so that the data do not appear to change
DoCmd.Echo False
' Remove the current recordsource so that the report can use it
Me.RecordSource = ""
DoCmd.OpenReport stDocName, acPreview, , strfilter
Exit_PrintJobSheet_Click:
' Restore the recordsource to what it was
Me.RecordSource = strRecordSource
' Restore the filter to what it was
Me.Filter = strFormFilter
' Turn filter back on
Me.FilterOn = True
' Return to the record that was active when the button was clicked
Me.RecordsetClone.FindFirst strfilter
Me.Bookmark = Me.RecordsetClone.Bookmark
' Unfreeze the screen
DoCmd.Echo True
Exit Sub
The code was originally provided to me from one of the Access Newsgroups a
couple of years ago & seemed to work perfectly. However, now that I've
started to use this button more, I'm finding that when I click the button I
get an error dialog of "No Current Record". When I click the OK button on
this dialog, I then get another error dialog of "No Current Record" that
continues to loop in the same way until I get fed up & press CTRL+Break!
Going into the VBA coding, when I'm in DeBug mode, I've also noticed that
when I hover my mouse over the line of coding line...
Me.Bookmark = Me.RecordsetClone.Bookmark,
then I have a (not sure of technical term, but it's like ControlTip Text)
of Me.Bookmark = <No Current Record.> which is obviously what's causing the
issue.
Interestingly, some jobs print out ok, it's only when I'm creating a new job
that the issue arises. I have a button on my form to save the job, & that
appears to work. I've even gone back to the version that I had before
putting through these mods & realised that that isn't working, either (so
I've satisfied myself that it's not something that I've done on this Mod!
I'm using Access XP (in Access 2000 mode) to write the database (but also
have Access 2000 & 2003 installed) & th epc that's using the database is on
Access 2000. The database is also slpit between front & back ends.
Hope there's enough there for you guys to work on.
Regards
Colin Foster