Searching Access Database from Solidworks VBA
Searching Access Database from Solidworks VBA
(OP)
Good Day,
Does anyone know the best way to pull information from an Access Database file. The values from the database are used as the input in a VBA macro. I can do it in Excel, but how do you set up a query in the VBA code to search for the record that matches specific criteria in the Access file.
Best Wishes,
Suzy
Does anyone know the best way to pull information from an Access Database file. The values from the database are used as the input in a VBA macro. I can do it in Excel, but how do you set up a query in the VBA code to search for the record that matches specific criteria in the Access file.
Best Wishes,
Suzy






RE: Searching Access Database from Solidworks VBA
I hope that helps.
RE: Searching Access Database from Solidworks VBA
You have to know the DataBase table set up, and the individual record/field data types.
You can then set up queries to return recordsets.
The good news is that with VBA, you can often just import a module written in another Office app (Excel, Access) to your SWX app, add an early binding reference, and run the code from there.
RE: Searching Access Database from Solidworks VBA
Dim db as object
Dim swRecord as Recordset
set db = opendatabase(string representing location of database)
set swRecord = db.openRecordset(string representing table or query name, dbOpenDynaset)
swrecord.MoveFirst
do until swRecord.EOF
something = swRecord![Column Name]
swRecord.MoveNext
Loop
swRecord.Close
db.Close
set swRecord = Nothing
Set db = Nothing
RE: Searching Access Database from Solidworks VBA