Adam Merrifield
Adam Merrifield

Reputation: 10407

Query MS Access Database from Form button with Visual Basic for Applications

Within my Microsoft Access Database I have a form object. This form object has just 1 button on it. I want this button to open a mailto link with all of the email addresses in my Customers table as the to field. I have the opening of the mailto with test data to make sure this works via Application.FollowHyperlink("mailto:[email protected],[email protected],[email protected]") which works fine.

I need to be able to be able to either query a database table/query from the VBA. Also if possible I'd preferably want it without an absolute path to the .accdb file as this file may be moved which would break this button completely.

I've tried Application.OpenCurrentDatabase("database.accdb") but that doesn't seem to be working.

Upvotes: 0

Views: 250

Answers (1)

Taotao
Taotao

Reputation: 168

If you want to open the default access db, you do not need to open the db again, you can just use the CurrentDB object.

And if you want to open other access db, my suggestion is save the absolute path to the current db table, and query this table to get the absolute path.

Upvotes: 1

Related Questions