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
 

Darren Smith

Well-known Member
Joined
Nov 23, 2020
Messages
631
Office Version
  1. 2019
Platform
  1. Windows
Sorry it`s this line
VBA Code:
Set rsQry = db.OpenRecordset("SELECT * FROM [ModelType]", dbOpenSnapshot)
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
39,338
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Where is the database located? An error like that is often to do with something like network connection issues, or AV software locking files.
 

Darren Smith

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

Forum statistics

Threads
1,176,008
Messages
5,900,836
Members
434,855
Latest member
backspace18

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
Top