M
Mike
hi,
i have an Inventory database for materials moving into
our shop, tblInventory, and a transaction table,
tblTransaction for materials moving out of our shop. On
the transaction form, I have a subform which is based on
a query that deducts quantity sold in transaction from
the UnitsIn in my tblInventory and displys the new
quantity in stock of certain product.
I have also a report that is used for invoices. On my
form I have put a command buttton which have a preceedue
and VB code that generates a 4-digits number, used for
Invoice number. There is a problem with this:
1- User must frist click this to generate a number and
then using a drop down menu choose a numnber to be
displey on the invoice, quite ineefficient.
I was wondering if someone can help me with a better,
efficient idea for generation of the invoice number, and
having an invoive printed by a single click. Also, I want
to add a dash and another two digits number to the
generated 4 digit number. Here is the code used to
generate the 4-digitds number.
Private Sub Command92_Click()
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
Thank you in advance for your help.
Mike
i have an Inventory database for materials moving into
our shop, tblInventory, and a transaction table,
tblTransaction for materials moving out of our shop. On
the transaction form, I have a subform which is based on
a query that deducts quantity sold in transaction from
the UnitsIn in my tblInventory and displys the new
quantity in stock of certain product.
I have also a report that is used for invoices. On my
form I have put a command buttton which have a preceedue
and VB code that generates a 4-digits number, used for
Invoice number. There is a problem with this:
1- User must frist click this to generate a number and
then using a drop down menu choose a numnber to be
displey on the invoice, quite ineefficient.
I was wondering if someone can help me with a better,
efficient idea for generation of the invoice number, and
having an invoive printed by a single click. Also, I want
to add a dash and another two digits number to the
generated 4 digit number. Here is the code used to
generate the 4-digitds number.
Private Sub Command92_Click()
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
Thank you in advance for your help.
Mike