I am trying to write code that will list the field names from a query. What I have so far is :
Dim db As Database
Dim fld As Field
Dim qry As QueryDef
Dim str As String
Dim i As Integer
Set qry = db.QueryDefs("MyQuery"
Set db = CurrentDb()
Set fld = qry.Fields
For i = 1 To qry.Fields.Count
str = qry.Fields(i).name
Debug.Print str
Next
Problem I get is an error message saying "Object variable or With block variable not set91" when I try to run it.
Can anybody piont out what Im doing wrong .
Thanks
Dim db As Database
Dim fld As Field
Dim qry As QueryDef
Dim str As String
Dim i As Integer
Set qry = db.QueryDefs("MyQuery"
Set db = CurrentDb()
Set fld = qry.Fields
For i = 1 To qry.Fields.Count
str = qry.Fields(i).name
Debug.Print str
Next
Problem I get is an error message saying "Object variable or With block variable not set91" when I try to run it.
Can anybody piont out what Im doing wrong .
Thanks