I think your best bet is to use the forms BeforeUpdate event. Something like:
Private Sub Form_BeforeUpdate(Cancel as integer)
me.txSomeControl.DefaultValue = me.txtSomeControl.Value + 1
End Sub
Then, when you go to the next record, that control should contain the value
you are looking for.
Thanks for the reply, Dale.
Yes, that works very good when data-entry is rolling along
normally. But in some fairly common cases, the wheels come
off. If someone gets interupted during data-entry and has
to come back later and pick up in the middle of a paper
form, there's no "update" event to set the DefaultValue for
the first record they need to add.
Aside from that, it is positive and simple (no domain lookup
necessary). I haven't ruled it out, but I'm still hoping
for something that covers all the bases.
Here's what I've settled on for the moment:
If Me.Parent.NewRecord Then
Me![txtCountPage].DefaultValue = 1
Me![txtCountLine].DefaultValue = 1
ElseIf Me![txtCountLine].DefaultValue < 34 Then
Dim strWhere As String
Dim strWhere2 As String
strWhere = "[CountSurvId] = " & _
Me.Parent![CountSurvId]
strWhere2 = "[CountSurvId] = " & _
Me.Parent![CountSurvId] & " _
And [CountPage] = " & _
Me![txtCountPage].DefaultValue
Me![txtCountPage].DefaultValue = _
Nz(DMax("CountPage", "tblCountDetail", _
strWhere), 1)
Me![txtCountLine].DefaultValue = _
Nz(DMax("CountLine", "tblCountDetail", _
strWhere2), 0) + 1
Me![txtCountLine].Requery
ElseIf Me![txtCountLine].DefaultValue >= 34 Then
Dim strWhere3 As String
Dim strWhere4 As String
strWhere3 = "[CountSurvId] = " & _
Me.Parent![CountSurvId]
strWhere4 = "[CountSurvId] = " & _
Me.Parent![CountSurvId] & " And _
[CountPage] = " & _
Me![txtCountPage].DefaultValue
Me![txtCountPage].DefaultValue = _
Nz(DMax("CountPage", "tblCountDetail", _
strWhere3), 1) + 1
Me![txtCountLine].DefaultValue = 1
Me![txtCountLine].Requery
End If
I also put a call for Form_Current on the AfterUpdate event
of those two fields, so that when a crossed-out line on the
paper requires skipping a number, and the data-entry clerk
has to get mousey, the DefaultValues will fix themselves.