Full Version: Modifying Query properties with VBA
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
tbrooks
Hi All,
Am new to this forum and hope that someone can help me. I wish to use some vba code to automate the initialization of query properties. Specifically, I want to set the value for the odbc connect string in an sql pass-through query.
The access help pages do say that this can be done, it doesnt show how though. Any help would be great.
Tz
schroep
CODE
  Dim qdf As DAO.QueryDef
nbsp; With CurrentDb
    Set qdf = .QueryDefs("queryname")
    qdf.Connect = "yourconnectionstringgoeshere"
    Set qdf = Nothing
  End With

Welcome to UA! cool.gif
tbrooks
Hey, this is great. However, I dont seem to have the add-ins in my ms access for data access objects. Would appreciate some pointers of how to get these.
z
truittb
You need to set a Reference to Microsoft Data Access Object 3.x in the VBE Menu Tools, References.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.