Need to set pass-thru query property

T

Tom

I'll bet I'm making this a lot harder than it has to be...

In this particular case I want to change the "ODBC connect str" property of my
pass-thru query. (And I'd like to know how to do it so I can any other property
which I might need to change.) Here's my code (GULP):

Public Function fncSetQryProp(strQryName As String, strPrpName As String, _
strPrpValue As String)
On Error GoTo Err_SetConnStrProp

Dim DAOqrydef As DAO.QueryDef
Dim DAOprp As DAO.Property

Set DAOqrydef = DAOdbs.QueryDefs(strQryName)

With DAOqrydef

DAOprp.Name = strPrpName
DAOprp.Value = strPrpValue

.Properties.Refresh

End With

Exit_SetConnStrProp:
On Error Resume Next
Exit Function

Err_SetConnStrProp:
MsgBox "Error # " & Err.Number & " was generated by " & Err.Source & vbCrLf
& _
Err.Description, , "SetConnStrProp"
Resume Exit_SetConnStrProp

End Function

If someone could please help, I'd sure appreciate it.

Thanks in advance,

Tom
 
D

Douglas J. Steele

Try

DAOqrydef.Properties(strPrpName) = strPrpValue

instead of

With DAOqrydef

DAOprp.Name = strPrpName
DAOprp.Value = strPrpValue

.Properties.Refresh

End With


Where have you declared and instantiated DAOdbs?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top