|
-
Aug 4th, 2000, 12:37 PM
#1
Thread Starter
Lively Member
If you want to create a QueryDef object at runtime here is an example from DAO help:
Code:
Sub CreateQueryDefX()
Dim dbsNorthwind As Database
Dim qdfTemp As QueryDef
Dim qdfNew As QueryDef
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
With dbsNorthwind
' Create temporary QueryDef.
Set qdfTemp = .CreateQueryDef("", _
"SELECT * FROM Employees")
' Open Recordset and print report.
GetrstTemp qdfTemp
' Create permanent QueryDef.
Set qdfNew = .CreateQueryDef("NewQueryDef", _
"SELECT * FROM Categories")
' Open Recordset and print report.
GetrstTemp qdfNew
' Delete new QueryDef because this is a demonstration.
.QueryDefs.Delete qdfNew.Name
.Close
End With
End Sub
Function GetrstTemp(qdfTemp As QueryDef)
Dim rstTemp As Recordset
With qdfTemp
Debug.Print .Name
Debug.Print " " & .SQL
' Open Recordset from QueryDef.
Set rstTemp = .OpenRecordset(dbOpenSnapshot)
With rstTemp
' Populate Recordset and print number of records.
.MoveLast
Debug.Print " Number of records = " & _
.RecordCount
Debug.Print
.Close
End With
End With
End Function
-
Aug 4th, 2000, 12:46 PM
#2
Frenzied Member
Sounded to me like he wanted to have one (actually 4) queries that serviced any table he creates. Like:
Function BuildSQL(tablename As String) as string
dim sSQL as string
sSQL= "select * from " & trim(tablename) & " where condition"
End Function
-
Aug 4th, 2000, 07:52 PM
#3
New Member
Exactlly right, JHausmann.
I could read the data back out, do the calc, and save the results to their own fields, although the operations are being done on 300+ point waveforms. I won't have a chance to try again till monday. Going back to the querry, I was able to sorta create querries using the db.CreateQueryDef method but they all end up in their own table. Is there a way to group them?
-
Aug 4th, 2000, 08:09 PM
#4
Frenzied Member
Not sure on what you want to group. if the structure of your results will always be the same (ie; data returned for any group of queries is of compatible type), you could union them into a temp table
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|