M
Mike
Hi,
I have this below code to generate automatic recipt
number by taking the first one and then increment it at
the next data entry.
Type of the feild in the tblSeries is Number and Long
Integer.
I have put this code in the before Insert property of my
data entry form but on entering any data I get data
mismatch with rst highlighted, or the .Edit highlighted.
I have the Microsoft DAO 3.6 engine checked as well.
This code has been working in my other database verywell.
Please Help.
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim rst As Recordset, db As Database
Dim lngNextNumber As Long
Set db = CurrentDb
'Open tblSeries, lock, read next number, increment,
'update and unlock.
Set rst = db.OpenRecordset("tblSeries", , dbDenyRead)
With rst
.MoveFirst
.Edit
lngNextNumber = ![NextNumber]
![NextNumber] = lngNextNumber + 1
.Update
End With
Set db = Nothing
End Sub
Regards,
Mike
I have this below code to generate automatic recipt
number by taking the first one and then increment it at
the next data entry.
Type of the feild in the tblSeries is Number and Long
Integer.
I have put this code in the before Insert property of my
data entry form but on entering any data I get data
mismatch with rst highlighted, or the .Edit highlighted.
I have the Microsoft DAO 3.6 engine checked as well.
This code has been working in my other database verywell.
Please Help.
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim rst As Recordset, db As Database
Dim lngNextNumber As Long
Set db = CurrentDb
'Open tblSeries, lock, read next number, increment,
'update and unlock.
Set rst = db.OpenRecordset("tblSeries", , dbDenyRead)
With rst
.MoveFirst
.Edit
lngNextNumber = ![NextNumber]
![NextNumber] = lngNextNumber + 1
.Update
End With
Set db = Nothing
End Sub
Regards,
Mike