I am creating a query for Excel to Access Database

Darren Smith

Well-known Member
Joined
Nov 23, 2020
Messages
631
Office Version
  1. 2019
Platform
  1. 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?

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
 
Do you have your combobox currently inked to a datasource using the RowSource property? If so, clear it.
 
Upvote 0
Solution

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,214,950
Messages
6,122,436
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top