Incomplete Query Clause

sross81

Registered User.
Local time
Today, 05:26
Joined
Oct 22, 2008
Messages
97
Hello,

I am trying to return a value from a table based on the value that a user selects from a combo box. I am trying to get my SQL statement to work and I keep getting an error that says Incomplete Query Clause. I have tried all kinds of options I found online but I can't seem to get it right. Any help would be greatly appreciated. Thanks in advance.

Dim strSQL As String

strSQL = "Select ID FROM 'Computer Inventory' " _
& "WHERE 'PC Name' = " & Me.cboComputerName.Value & ""
CurrentDb.Execute strSQL, dbFailOnError
 
I believe you have to end your SQL statement with ;
 
I think I got it figured out now. Here is what I did in case anyone wants to use it for help.

Dim strSQL As String
strSQL = "Select ID FROM [Computer Inventory] " _
& "WHERE [PC Name] = '" & Me.cboComputerName & "'"

I guess its bad practice to put spaces in column names so I put brackets around them and that helped. Also you cannot use a currentdb.execute statement with a select statement.
 

Users who are viewing this thread

Back
Top Bottom