|
-
Mar 28th, 2000, 07:06 PM
#1
Thread Starter
Hyperactive Member
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:
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
Thanks for your help. 
JazzBass
-
Mar 28th, 2000, 09:56 PM
#2
Lively Member
You have to add a new query to the querys collection and then open this new query. Unfortunatelly I'm not at my machine, so I can't provide you any code. Hope it helps anyway.
Roger
-
Mar 29th, 2000, 12:32 AM
#3
Thread Starter
Hyperactive Member
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
|