Darren Smith
Well-known Member
- Joined
- Nov 23, 2020
- Messages
- 631
- Office Version
- 2019
- Platform
- Windows
I`ve set a function code up to find the correct value.
Then tried to add it to the qry code it says "Argument not optional
Please let me know why Thanks in advance
Then tried to add it to the qry code it says "Argument not optional
Please let me know why Thanks in advance
VBA Code:
Private Sub Decals_Type_Click()
Dim cbo As ComboBox
Dim wsSource As Worksheet
Dim wsDest As Worksheet
Dim Addme As Range, Rng As Range
Dim iRow As Long
Dim qry As String
Dim val As String
Dim BodyType As String
Set wsSource = ThisWorkbook.Sheets("Part_Group_Items_ List")
Set wsDest = ThisWorkbook.Sheets("Job Card Master")
With wsDest
iRow = Selection.Row
Set Addme = wsDest.Range("A" & iRow)
Set cbo = Decals_Type
If cbo.Value = "Tippa" Then
Set BodyType = FindTippa
qry = "SELECT * FROM [Decals] " & _
" WHERE [DecalType]='" & BodyType.Text & "'"
iRow = iRow
Dim rs As Object: Set rs = OpenConAndGetRS(qry)
If Not (rs.BOF Or rs.EOF) Then
Do While Not rs.EOF
.Cells(iRow, 3) = rs.Fields("Decription").Value
.Cells(iRow, 4) = rs.Fields("TGSPartNo").Value
.Cells(iRow, 5) = rs.Fields("Material/Part").Value
.Cells(iRow, 7) = rs.Fields("Size").Value
.Cells(iRow, 8) = rs.Fields("Qty").Value
iRow = iRow + 1
rs.MoveNext
Loop
End If
rs.Close: Set rs = Nothing
End If
If cbo.Value = "Dropside" Then
End If
If cbo.Value = "Bevalite" Then
End If
End Sub
Function FindTippa(Source As String, Position As Integer)
Dim ws As Worksheet
Dim arr() As String
Set ws = ThisWorkbook.Worksheets("Job Card Master")
arr = VBA.Split(ws.Range("E4"), " ")
xCount = UBound(arr)
If xCount < 1 Or (Position - 1) > xCount Or Position < 0 Then
Tippa = ""
Else
Tippa = arr(Position - 1)
End If
End Function