Please check your data first.
Has it incremented on the tblreports table? Before or after running this code?
Are there duplicates? Dlookup starts with the oldest record.
Main Topics
Browse All TopicsA week or so ago someone helped me with a run counter incrementing by 1 every time the reporet was launched. For some reason it has stopped working.
Here is the code I was provided. Have I somehow broken something?
On Open Event:
nextno = DLookup("RunCounter", "tblReports", "ReportName ='" & Me.Name & "'") + 1
Report Header Format Event:
Me.txtReportNumber = nextno
Report Footer Print Event:
CurrentDb.Execute "Update tblreports set RunCounter= " & nextno & " where ReportName ='" & Me.rptProdSkedRptGrpdByMol
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The code you posted here has never worked. You must have changed it from the working version.
This command is wrong.
CurrentDb.Execute "Update tblreports set RunCounter= " & nextno & " where ReportName ='" & Me.rptProdSkedRptGrpdByMol
It should be either..
CurrentDb.Execute "Update tblreports set RunCounter= " & nextno & " where ReportName = 'rptProdSkedRptGrpdByMoldS
or
CurrentDb.Execute "Update tblreports set RunCounter= " & nextno & " where ReportName ='" & Me.Name & "'", dbFailOnError
Business Accounts
Answer for Membership
by: SteveL13Posted on 2009-11-08 at 09:14:53ID: 25771034
Here is all of the code for the report in case someone can figure out what I've done wrong:
olor = shadedColor olor = normalColor
As Integer, FormatCount As Integer)
As Integer, FormatCount As Integer)
dSec & "'", dbFailOnError
Option Compare Database
Option Explicit
Dim nextno As Long
Private shadeNextRow As Boolean
Const shadedColor = 12632256
Const normalColor = 16777215
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo Detail_Format_Error
' Choose a color based on the shadeNextRow value
If shadeNextRow = True Then
Me.Section(acDetail).BackC
Else
Me.Section(acDetail).BackC
End If
' Switch the color for the next row
shadeNextRow = Not shadeNextRow
Detail_Format_Exit:
Exit Sub
Detail_Format_Error:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Detail_Format_Exit
End Sub
Private Sub GroupHeader0_Format(Cancel
shadeNextRow = False
End Sub
Private Sub Report_Close()
DoCmd.Restore
End Sub
Private Sub Report_NoData(Cancel As Integer)
MsgBox "No data exists for this molding section within this date range."
DoCmd.Close
End Sub
Private Sub Report_Open(Cancel As Integer)
nextno = DLookup("RunCounter", "tblReports", "ReportName ='" & Me.Name & "'") + 1
End Sub
Private Sub ReportHeader_Format(Cancel
Me.txtReportNumber = nextno
shadeNextRow = False
End Sub
Private Sub ReportFooter_Print(Cancel As Integer, PrintCount As Integer)
CurrentDb.Execute "Update tblreports set RunCounter= " & nextno & " where ReportName ='" & Me.rptProdSkedRptGrpdByMol
End Sub