D
Daama via AccessMonster.com
I am using CreateQueryDef to create a query named: "User Query".
But it does not show up in my query window and I cannot open by using DoCmd
procedure.
Can anyone help me to make this query shop up as one of the queries in my
database one it is created. The code already works. If run the code a second
time it tells me that the query already exist. So, it is doing the work. The
problem is that I can see my query. I'd appreciate any help..
Daama.
Code:
Private Sub RunQuery()
Dim cn As ADODB.Connection
Dim db As Database
Dim qdf As QueryDef
Dim qdfNew As New QueryDef
Set db = OpenDatabase("faith fund Database")
With db
Set qdf = .CreateQueryDef("User Query", _
"Select * from buyer")
GetRS qdfNew
.QueryDefs.Delete qdfNew.Name
.Close
End With
'DoCmd.OpenQuery ("user Query")
End Sub
Function GetRS(qdf As QueryDef)
Dim RS As ADODB.Recordset
With qdf
Debug.Print .Name
Debug.Print "" & .SQL
Set RS = .OpenRecordset(dbOpenSnapshot)
With RS
.MoveLast
Debug.Print " number of records =" & _
.RecordCount
Debug.Print
.Close
End With
End With
End Function
But it does not show up in my query window and I cannot open by using DoCmd
procedure.
Can anyone help me to make this query shop up as one of the queries in my
database one it is created. The code already works. If run the code a second
time it tells me that the query already exist. So, it is doing the work. The
problem is that I can see my query. I'd appreciate any help..
Daama.
Code:
Private Sub RunQuery()
Dim cn As ADODB.Connection
Dim db As Database
Dim qdf As QueryDef
Dim qdfNew As New QueryDef
Set db = OpenDatabase("faith fund Database")
With db
Set qdf = .CreateQueryDef("User Query", _
"Select * from buyer")
GetRS qdfNew
.QueryDefs.Delete qdfNew.Name
.Close
End With
'DoCmd.OpenQuery ("user Query")
End Sub
Function GetRS(qdf As QueryDef)
Dim RS As ADODB.Recordset
With qdf
Debug.Print .Name
Debug.Print "" & .SQL
Set RS = .OpenRecordset(dbOpenSnapshot)
With RS
.MoveLast
Debug.Print " number of records =" & _
.RecordCount
Debug.Print
.Close
End With
End With
End Function