Darren Smith
Well-known Member
- Joined
- Nov 23, 2020
- Messages
- 631
- Office Version
- 2019
- Platform
- Windows
I`ve created a VBA query to not find various data see below. How could I make this work?
At the moment the Qry only shows red?
At the moment the Qry only shows red?
VBA Code:
Private Sub Fill_DrNos()
TurnOff
If bReset = True Then Exit Sub
Dim qry As String
Dim i As Variant
Dim prevPos As Long
qry = "SELECT DISTINCT JobCardMaster.F2 FROM JobCardMaster" & _
" WHERE (JobCardMaster.F2 Is Not Null) " & _
And JobCardMaster.F2 Not Like "Drawing No." & _
And JobCardMaster.F2 Not Like "Drawing No." & "'"
Application.EnableEvents = False
Dim rs As Object: Set rs = OpenConAndGetRS(qry)
If Not (rs.BOF Or rs.EOF) Then
With Me.Print_DrNos
prevPos = .ListIndex
.Clear
Do Until rs.EOF
.AddItem (rs.Fields("F2").Value)
rs.MoveNext
Loop
.ListIndex = prevPos
End With
End If
rs.Close: Set rs = Nothing
TurnOn
End Sub