Hello, All!
Please see
http://p2p.wrox.com/topic.asp?TOPIC_ID=5398 for a description of my problem and the solutions that have gone before.
All seems to be working fine with the following code in my Form's "Current" event:
Private Sub Form_Current()
Dim datCur As Date
Dim datMax As Date
Dim intDailyID As Integer
datCur = Me!DateIn
datMax = Nz(FMax("SELECT MAX(DateIn) FROM Documents"), Date)
If Me.NewRecord Then
If datCur = datMax Then
intDailyID = Nz(FMax("SELECT MAX(DailyID) FROM Documents " & _
"WHERE DateIn = #" & Me!DateIn & "#"), 0) + 1
Else
intDailyID = 1
End If
Me!DailyID = intDailyID
End If
End Sub
Public Function FMax(strSQL As String) As Variant
Dim rst As ADODB.Recordset
Dim intCount As Integer
Set rst = New ADODB.Recordset
rst.Open strSQL, CurrentProject.Connection, adOpenStatic
If IsNull(rst(0)) Then
FMax = Null
Else
FMax = rst(0)
End If
rst.Close
Set rst = Nothing
End Function
HOWEVER: After my "DailyID" increments to "10" it will not go beyond ten; in other words, no "11", "12", etc. I'm not sure what the problem is but I must get it fixed before tomorrow evening!! (Dontcha hate deadlines!!!)
Thanks in advance!
Scott