Amend Query Properties

B

Ben

I am trying to use vb code to change the source database
and destination database of an ammend query.
I am using the following code:

Private Sub cmdaddrec_Click()


Dim qry As QueryDef
Dim prp As Property
Dim qry2 As QueryDef
Dim prp2 As Property

For Each qry In CurrentDb.QueryDefs
For Each prp In qry.Properties
If prp.name = "Source Database" Then
prp.Value = Text0.Text
End If
Next prp
Next qry

For Each qry2 In CurrentDb.QueryDefs
For Each prp2 In qry2.Properties
If prp2.Value = "Destination DB" Then
prp2.Value = Text5.Text
End If
Next prp2
Next qry2

Exit Sub

Err_cmdaddrec_Click:
MsgBox "One or more databases could not be found!"

End Sub

The problem is that the source and destination database
property name isn't in the qry.properties list. Can anyone
help?
 

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