Ok, How do you set the criteria fields from VB6? I want to only return records that meet two criteria which is picked from list boxes on the current form.
I am able to open the query, but then I am stuck. Thanks!
Printable View
Ok, How do you set the criteria fields from VB6? I want to only return records that meet two criteria which is picked from list boxes on the current form.
I am able to open the query, but then I am stuck. Thanks!
For access, crystal, or data report?
Sorry...in Access, but I am not doing it with a data environment since it still does not work.
Sorry, but I have not used the DE before, but I think the query, if
in access, would need to have the parameters already created.
Also, if the table does not contain too many records then you
could do a ADO filter, that is if you are using ADO.
What are you using to connect to Access? The DE
connectionstring built as ???
So far, I am able to connect to my database and open my query with the following code. Now I need to pass a variables from two fields, Level and Phase to get my recordset used to generate a random test.
Private Sub PRINT_Click()
'On Error Resume Next
Dim objAccess As Access.Application
'Dim rst As DAO.Recordset
'Dim rstTest As DAO.Recordset
Dim z As Integer
Dim Mz As Integer
Set objAccess = CreateObject("Access.Application")
With objAccess
.OpenCurrentDatabase "c:\PMEL\PMEL.mdb"
.Visible = True
.DoCmd.OpenQuery "Level", acViewDesign
(this code works, just got tired of printing the wrong info)
'.DoCmd.OpenReport "TestQuestions", acPreview
'.DoCmd.PrintOut
'.DoCmd.Close
'.DoCmd.OpenReport "TestAnswers", acPreview
'.DoCmd.PrintOut
'.DoCmd.Close
'.CloseCurrentDatabase
'Set objAccess = Nothing
Gen_Test.Hide
Main_Menu.Show
End With
objAccess.QUIT
End Sub
I believe there is a parameters collection or object in access that
you need to use. Either that or alter the query with the
parameters hard coded. Then save and run the report.