No one will be opening the report but me, but each time I open it, something
is altered because end-users are constantly putting in data. I need to
[quoted text clipped - 5 lines]
FWIW, here's how I got it to work...
On my report, I have a textbox with the following ControlSource:
=DMax("RunNumber","ReportRuns","[ReportName]='" & [Name] & "'")
I also have a table, ReportRuns(ReportName (text), RunDateStamp (date/Time,
general date), RunNumber (int))
PK is ReportName, RunDateStamp
Code...
Option Compare Database
Option Explicit
Private Sub Report_Open(Cancel As Integer)
Dim strInsertSQL As String
Dim intRunNumber As Integer
'grab the next run number from the table.
intRunNumber = Nz(DMax("RunNumber", "ReportRuns", "[ReportName]='" & Me.
Name & "'"), 0) + 1
' create the insert statement
strInsertSQL = "INSERT INTO ReportRuns(ReportName, RunNumber) VALUES ('"
& Me.Name & "' ," & intRunNumber & ")"
DBEngine(0)(0).Execute strInsertSQL
End Sub