Database issue

Darren Smith

Well-known Member
Joined
Nov 23, 2020
Messages
631
Office Version
  1. 2019
Platform
  1. Windows
For some reason my

VBA Code:
Dim db as DataBase

says Compile error User-defined type not defined. Does anybody know why it`s driving me mad

VBA Code:
Private Sub Combobox_List()

    Dim rsQry As Recordset
    Dim Qry As String
    Dim i As Long
    Dim db As DataBase
    Dim dbPath As String
    
Qry = "SELECT * FROM VehicleData"
dbPath = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\TGS-SRV01\Share\ShopFloor\PRODUCTION\DLS Cardworker\Access Files\DrNo Data Base.accdb;"
Set db = DBEngine.workspaces(0).OpenDatabase(dbPath)
Set rsQry = db.OpenRecordset(db, dbOpenSnapshot)
Model_Type.Clear

i = 0
While Not rsQry.EOF
'ModelType.AddItem
Me.Model_Type.List(i, 1) = rs.Fields("ModelType").Value
rs.MoveNext
i = i + 1
Wend
rs.Close

   
End Sub
 
Sorry it`s this line
VBA Code:
Set rsQry = db.OpenRecordset("SELECT * FROM [ModelType]", dbOpenSnapshot)
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Where is the database located? An error like that is often to do with something like network connection issues, or AV software locking files.
 
Upvote 0
It`s located in the same folder as the excel sheet. I have just opened it up and there is nothing wrong with the database as far as I know
 
Upvote 0

Forum statistics

Threads
1,223,879
Messages
6,175,145
Members
452,615
Latest member
bogeys2birdies

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