M
Mike
Hi,
I have this frmpayment boubded to tblA. on this for i
have a feild called ReciptNumber. I want to use the code
below to generate these recipt numbers but I have to
define the first number so that the code can increment
it. We buy these recipt books from outside and each time
we buy one it contains a different 7 digits number. I
want to modify the code to take the first number entered
as ReceiptNumber and the increment it and so on. I think
defining a varibale should be one way to approach this
but given my migger knowledge of VB I don't knoe how to
do that. Please help resolving this issue with your
help/suggestion/recommendation or any available code that
does this trick. I thank you in advance for you rhelp.
here is the code that I have used for a different reason
in a different database:
Private Sub Form_Load()
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
Set rst = db.OpenRecordset("tblInvoice", , dbDenyRead)
With rst
..MoveFirst
..Edit
lngNextNumber = lngNextNumber
![InvoiceNumber] = lngNextNumber + 1
..AddNew
![InvoiceNumber] = lngNextNumber + 1
..Update
End With
End With
rst.Close
Set db = Nothing
Call PrductListReq
End Sub
I have this frmpayment boubded to tblA. on this for i
have a feild called ReciptNumber. I want to use the code
below to generate these recipt numbers but I have to
define the first number so that the code can increment
it. We buy these recipt books from outside and each time
we buy one it contains a different 7 digits number. I
want to modify the code to take the first number entered
as ReceiptNumber and the increment it and so on. I think
defining a varibale should be one way to approach this
but given my migger knowledge of VB I don't knoe how to
do that. Please help resolving this issue with your
help/suggestion/recommendation or any available code that
does this trick. I thank you in advance for you rhelp.
here is the code that I have used for a different reason
in a different database:
Private Sub Form_Load()
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
Set rst = db.OpenRecordset("tblInvoice", , dbDenyRead)
With rst
..MoveFirst
..Edit
lngNextNumber = lngNextNumber
![InvoiceNumber] = lngNextNumber + 1
..AddNew
![InvoiceNumber] = lngNextNumber + 1
..Update
End With
End With
rst.Close
Set db = Nothing
Call PrductListReq
End Sub