Link to home
Start Free TrialLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

asked on

Why is this VBA failing?

I am very new to VBA and need to use an event to establish a database connection. But it's throwing an error when I add in this code:

Dim Myconnection As Connection
    Dim Myrecordset As Recordset
    Dim MyWorkbook As String

Why? These are just variable definitions. RIght?

Confused...

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of curiouswebster

ASKER

I find the User Type not defined is the error. How do I define it?
What is the error?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks. How do I reference it in Excel 2007?
I do not see Tools.
It's in the VBE menus, not the Excel application menus.

Kevin
Is that a button? Where is Tools in Excel 2007?
While looking at the Excel workbook, press ALT+F11 to switch to the VBE. You will then see the Tools menu.

Kevin
Thanks!