Avoraightu
New member
- Local time
- Today, 05:01
- Joined
- Mar 5, 2020
- Messages
- 28
I'm having a bit of trouble with my code:
What I am trying to do is generate a list of serial numbers to be inserted.
On the main form I have 3 main fields: Model, DateCode, Quantity
The user selects a model, and determines how many numbers they need.
The Date Code is generated on the form based on the date selected on the mini calendar of the date field.
So far I can get it to generate "n" numbers but I am struggling to get a list of those numbers into a single message box.
I have tried putting a messagebox before "Next i" and I get one message box for every serial number.
If I put it after the "Next i" I only get one message box with the last serial on it.
Once I have a list of numbers to display to the user, I will give them the option to print and insert the numbers into the table.
Thanks in advance
Code:
Dim strModel As String
Dim strDateCode As String
Dim strMsg As String
Dim nValue As Variant
Dim nQuantity As Variant
Dim i As Integer
If IsNull(Me.DateCode) Or IsNull(Me.ModelNumber) Or IsNull(Me.Quantity) Then
MsgBox "Please ensure that all fields have been filled in.", vbExclamation
Exit Sub
Else
strModel = Me.ModelNumber
strDateCode = Me.DateCode
nQuantity = Me.Quantity
End If
For i = 1 To nQuantity
nValue = Me.subqryTEGSystemNumbers!AutoNumber + i
If Me.ComboDC = "YES" Then
strMsg = strModel & "-" & nValue & "-" & strDateCode
Else
strMsg = strModel & "-" & nValue
End If
Next i
What I am trying to do is generate a list of serial numbers to be inserted.
On the main form I have 3 main fields: Model, DateCode, Quantity
The user selects a model, and determines how many numbers they need.
The Date Code is generated on the form based on the date selected on the mini calendar of the date field.
So far I can get it to generate "n" numbers but I am struggling to get a list of those numbers into a single message box.
I have tried putting a messagebox before "Next i" and I get one message box for every serial number.
If I put it after the "Next i" I only get one message box with the last serial on it.
Once I have a list of numbers to display to the user, I will give them the option to print and insert the numbers into the table.
Thanks in advance