M
Mark Kubicki
I have a function (PrintOrder -see below) that fires as the default value
for a textbox on a continuous subform
(It sets a value of the field based on what entries have been previously
made...)
The calculation SHOULD include the record i am currently editing
The problem:
When I start typing in a new record, Access generates a new "new record";
however, the default value for the text box (in the new "new record") is
incorrect .. The function it does not yet take into account the record
that I am currently editing.
for example:
- the record set contains in [PrintOrder] values: 2, 3, and 5 (in 3
records)
- the next record to be entered (the NEW RECORD) ought to have,
[txtPrintOrder].default value of 6
- once i start typing in the NEW RECORD, a new "NEW RECORD" is
generated; the default value for [txtPrintOrder] should be 7; HOWEVER, what
i get is another 6
- once i start typing in that new NEW RECORD, a new NEW RECORD is
generated with a [txtPrintOrder]value of 7; by now, it ought to be 8
- I'm sort of doing a reverse leap-frog (i get values,for the above
example of 2, 3, 5, 6, 6, 7, 7, 8...
I thought that including the update method in my code might help, but it
is not
Any suggestions would be greatly appreciated.
-Mark
'Update the recordset
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("tblInstallationNotes", dbOpenDynaset)
Rs.Edit
Rs.Update
vStr = "[Type] = '" & frm.Parent.Type & "'"
varx = DLookup("[Type]", "tblInstallationNotes", vStr)
vLen = Len(Nz(varx))
If vLen > 0 Then
Printorder = DMax("[PrintOrder]", "tblInstallationNotes", "[Type] =
'" & Forms![Spec].Type & "'") + 1
Else
Printorder = 1
End If
End Function
for a textbox on a continuous subform
(It sets a value of the field based on what entries have been previously
made...)
The calculation SHOULD include the record i am currently editing
The problem:
When I start typing in a new record, Access generates a new "new record";
however, the default value for the text box (in the new "new record") is
incorrect .. The function it does not yet take into account the record
that I am currently editing.
for example:
- the record set contains in [PrintOrder] values: 2, 3, and 5 (in 3
records)
- the next record to be entered (the NEW RECORD) ought to have,
[txtPrintOrder].default value of 6
- once i start typing in the NEW RECORD, a new "NEW RECORD" is
generated; the default value for [txtPrintOrder] should be 7; HOWEVER, what
i get is another 6
- once i start typing in that new NEW RECORD, a new NEW RECORD is
generated with a [txtPrintOrder]value of 7; by now, it ought to be 8
- I'm sort of doing a reverse leap-frog (i get values,for the above
example of 2, 3, 5, 6, 6, 7, 7, 8...
I thought that including the update method in my code might help, but it
is not
Any suggestions would be greatly appreciated.
-Mark
Public Function PrintOrder(frm As Access.Form)
'Update the recordset
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("tblInstallationNotes", dbOpenDynaset)
Rs.Edit
Rs.Update
vStr = "[Type] = '" & frm.Parent.Type & "'"
varx = DLookup("[Type]", "tblInstallationNotes", vStr)
vLen = Len(Nz(varx))
If vLen > 0 Then
Printorder = DMax("[PrintOrder]", "tblInstallationNotes", "[Type] =
'" & Forms![Spec].Type & "'") + 1
Else
Printorder = 1
End If
End Function