I'm trying to run a query and display the results in a popup window like it would if you ran a query using the query design wizard.
When I run the following, I get a "Microsoft Access cannot find the object: " and then it states the query string.
What am I doing wrong?
I am very new to databases using VBA and VB
Here is my code:
Thanks for your help.Code:Sub cmdUpdate_Click() Dim dbs As Database Dim strVariable As String strVariable = Forms!StateSelectNew.cmbStateSelect Set dbs = CurrentDb strSQL = "SELECT DISTINCT * FROM OTC_SITES WHERE [SITE_STATE] = " & "'" & strVariable & "'" DoCmd.OpenQuery strSQL, acViewNormal, acReadOnly Set dbs = Nothing End Sub
JazzBass





Reply With Quote