Hi, im really need help, just a bit pressured to sort this out as soon as possible,
I have a form were depending on the quantity that is them amount of inputboxes appear to fill a cylinder with a particualr product. Even if there are two products, it only asks for one cylinder number, this was working previously but dont know what is wrong, please help.
I have used "For i = 1 To Quantity" "Next i" withint the code to try and pick up the quantity
Heres is my code
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim rs2 As DAO.Recordset
Dim strSQL As String
Dim i As Integer
Dim tringy As Integer
Dim Stringy As String
Dim Stringy1 As String
Dim Stringy2 As Integer
Dim Stringy3 As Date
Dim sql
Dim valid As Boolean
Dim validdate As Boolean
valid = False
validdate = False
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl_transactionmaster")
For i = 1 To Quantity
While valid = False
Stringy = InputBox("You Are About To Fill A Cylinder For (Works Order Number):-" & [Works Order Number] & "..And For..(Line Number):- " & [Line Number] & "...", "Please Enter/Scan Cylinder Serial Number")
If StrPtr(Stringy) <> 0 Then
strSQL = "SELECT * FROM [tbl_CylinderMaster] WHERE [Cylinder Serial Number] = '" & Stringy & "' "
Set rs2 = db.OpenRecordset(strSQL)
If rs2.EOF Then
rs2.close
MsgBox "Not a valid cylinder number. Please re-check", vbCritical, "Invalid Cyclinder Number"
Else
valid = True
End If
Else
Exit Sub
End If
Wend
While validdate = False
Stringy1 = InputBox("Please Input The Transaction Date, (DD / MM / YY)", "Spec Gas System", Me!Text20 & "")
If StrPtr(Stringy1) <> 0 Then
If IsDate(Stringy1) = False Then
MsgBox "The date you have entered is not valid. Please enter a date in the form of DD/MM/YY", vbCritical, "Invalid Date"
Else
validdate = True
End If
Else
Exit Sub
End If
Wend
If [Batch Number] = True Then
Stringy2 = InputBox("Please Input The Batch Number")
End If
If [Expiration Required] = True Then
Stringy3 = InputBox("Please Enter the Expiration Date, (DD / MM / YY)", Me!Text20 & "")
End If
If Stringy <> "" Then
rs.AddNew
rs![Works Order Number] = Me![Works Order Number]
rs![Line Number] = Me![Line Number]
rs!CustNo = Me!CustNo
rs!ProdNo = Me!ProdNo
rs!Status = "Available To Deliver"
rs![Cylinder Number] = Stringy
rs![Transaction Date] = Stringy1
rs![Batch Number] = Stringy2
rs![Expiration Required] = Stringy3
rs.Update
sql = "UPDATE [AberdeenWOLines] SET Status = 'Filled' WHERE WorksOrderNumber = '" & Me![Works Order Number] & "' "
sql = sql & "AND [Line Number] = '" & Me![Line Number] & "'"
db.Execute (sql)
Me.Refresh
End If
Next i
rs.close
db.close
End Sub
I have a form were depending on the quantity that is them amount of inputboxes appear to fill a cylinder with a particualr product. Even if there are two products, it only asks for one cylinder number, this was working previously but dont know what is wrong, please help.
I have used "For i = 1 To Quantity" "Next i" withint the code to try and pick up the quantity
Heres is my code
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim rs2 As DAO.Recordset
Dim strSQL As String
Dim i As Integer
Dim tringy As Integer
Dim Stringy As String
Dim Stringy1 As String
Dim Stringy2 As Integer
Dim Stringy3 As Date
Dim sql
Dim valid As Boolean
Dim validdate As Boolean
valid = False
validdate = False
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl_transactionmaster")
For i = 1 To Quantity
While valid = False
Stringy = InputBox("You Are About To Fill A Cylinder For (Works Order Number):-" & [Works Order Number] & "..And For..(Line Number):- " & [Line Number] & "...", "Please Enter/Scan Cylinder Serial Number")
If StrPtr(Stringy) <> 0 Then
strSQL = "SELECT * FROM [tbl_CylinderMaster] WHERE [Cylinder Serial Number] = '" & Stringy & "' "
Set rs2 = db.OpenRecordset(strSQL)
If rs2.EOF Then
rs2.close
MsgBox "Not a valid cylinder number. Please re-check", vbCritical, "Invalid Cyclinder Number"
Else
valid = True
End If
Else
Exit Sub
End If
Wend
While validdate = False
Stringy1 = InputBox("Please Input The Transaction Date, (DD / MM / YY)", "Spec Gas System", Me!Text20 & "")
If StrPtr(Stringy1) <> 0 Then
If IsDate(Stringy1) = False Then
MsgBox "The date you have entered is not valid. Please enter a date in the form of DD/MM/YY", vbCritical, "Invalid Date"
Else
validdate = True
End If
Else
Exit Sub
End If
Wend
If [Batch Number] = True Then
Stringy2 = InputBox("Please Input The Batch Number")
End If
If [Expiration Required] = True Then
Stringy3 = InputBox("Please Enter the Expiration Date, (DD / MM / YY)", Me!Text20 & "")
End If
If Stringy <> "" Then
rs.AddNew
rs![Works Order Number] = Me![Works Order Number]
rs![Line Number] = Me![Line Number]
rs!CustNo = Me!CustNo
rs!ProdNo = Me!ProdNo
rs!Status = "Available To Deliver"
rs![Cylinder Number] = Stringy
rs![Transaction Date] = Stringy1
rs![Batch Number] = Stringy2
rs![Expiration Required] = Stringy3
rs.Update
sql = "UPDATE [AberdeenWOLines] SET Status = 'Filled' WHERE WorksOrderNumber = '" & Me![Works Order Number] & "' "
sql = sql & "AND [Line Number] = '" & Me![Line Number] & "'"
db.Execute (sql)
Me.Refresh
End If
Next i
rs.close
db.close
End Sub