M
mattc66 via AccessMonster.com
I have the following code and it works okay, but I need to change how my
serial number is created.
Right now the user inputs the Serial# starting with the first 7 digits as
follows:
K05-123
Then the below code adds a "-" followed by 3 digits starting with 001 until
it reaches the qty entered by the user.
I actual need the user to input the serial# as following (example): K05-123-
020 or in other words they need to enter the starting serial number. From
then on I need the code to assign a sequenctial number from that point until
it reach's the qty input.
Example if they input K05-123-020 and a qty of 5 it would create the
following serial numbers:
K05-123-020
K05-123-021
K05-123-022
K05-123-023
K05-123-024
K05-123-025
Can anyone give me some assitance?
-------------------------------->Current Code-------------------------
Private Sub cmdSeqCreate_Click()
Dim Qty As Integer
Qty = Me.Qty
Dim Serial As String
Serial = Me.Serial
Dim Item As String
Item = Me.Item
Dim UserIntials As String
UserIntials = Me.UserIntials
Dim db As Database
Set db = CurrentDb
Set rs = db.OpenRecordset("tblSeqNumRooms", dbOpenTable)
Do While Qty <> 0
rs.AddNew
rs.Item = Item
rs.Qty = Qty
rs.UserIntials = UserIntials
rs.SerialNum = Serial & "-" & Format(Qty, "000")
rs.Update
Qty = Qty - 1
Loop
rs.Close
End Sub
serial number is created.
Right now the user inputs the Serial# starting with the first 7 digits as
follows:
K05-123
Then the below code adds a "-" followed by 3 digits starting with 001 until
it reaches the qty entered by the user.
I actual need the user to input the serial# as following (example): K05-123-
020 or in other words they need to enter the starting serial number. From
then on I need the code to assign a sequenctial number from that point until
it reach's the qty input.
Example if they input K05-123-020 and a qty of 5 it would create the
following serial numbers:
K05-123-020
K05-123-021
K05-123-022
K05-123-023
K05-123-024
K05-123-025
Can anyone give me some assitance?
-------------------------------->Current Code-------------------------
Private Sub cmdSeqCreate_Click()
Dim Qty As Integer
Qty = Me.Qty
Dim Serial As String
Serial = Me.Serial
Dim Item As String
Item = Me.Item
Dim UserIntials As String
UserIntials = Me.UserIntials
Dim db As Database
Set db = CurrentDb
Set rs = db.OpenRecordset("tblSeqNumRooms", dbOpenTable)
Do While Qty <> 0
rs.AddNew
rs.Item = Item
rs.Qty = Qty
rs.UserIntials = UserIntials
rs.SerialNum = Serial & "-" & Format(Qty, "000")
rs.Update
Qty = Qty - 1
Loop
rs.Close
End Sub