HI I HAVE WANT TO MAKE A PARAMETER QUERY WHOSE PPARAMETERS ARE PASSED BY THE USER AFER SELECTING IT FROM THE COMBOBOX. I HAVE USED THE CODE BELOW, BUT THE QUERY ONLY WORKS THE FIRST TIME THE USER CLICS FIND THE SECOND TIME WHEN THE USER TRIES TO RUN THE QUERY HE GETS AN ERROR, SAYING THAT MyQuery ALREADY EXISTS. IS THERE ANY OTHER WAY TO RUN THE QUERY, I DON'T WANT TO SAVE OR MAKE A QUERY EVERYTIME THE USER CLICKS ON FIND, JUST WANT TO RUN IT..
PLEASE HELP...
Private Sub cmdFind_Click()
Dim dbMyDB As Database
Dim qdMyQuery As QueryDef
Dim rsMyRS As Recordset
Dim strMySQL As String
Dim lngParam As Long
Dim RItem As Integer
strMySQL = " Select * from ClientDisplayQuery WHERE [Product].[ClientDisplay] = '" & cmbCName.Column(RItem) & "';"
Set dbMyDB = CurrentDb
Set qdMyQuery = dbMyDB.CreateQueryDef("MyQuery", strMySQL)
DoCmd.OpenQuery qdMyQuery.Name
End Sub
PLEASE HELP...
Private Sub cmdFind_Click()
Dim dbMyDB As Database
Dim qdMyQuery As QueryDef
Dim rsMyRS As Recordset
Dim strMySQL As String
Dim lngParam As Long
Dim RItem As Integer
strMySQL = " Select * from ClientDisplayQuery WHERE [Product].[ClientDisplay] = '" & cmbCName.Column(RItem) & "';"
Set dbMyDB = CurrentDb
Set qdMyQuery = dbMyDB.CreateQueryDef("MyQuery", strMySQL)
DoCmd.OpenQuery qdMyQuery.Name
End Sub