Syntax error?

A

AJ

I am trying to run the code below and am getting a syntax erroe missing
operator in query expression 'dmanumber = and density='
ANy ideas???

Sub Load_storeperiods()
Dim conDatabase As ADODB.Connection
Dim strSQL As String
Dim rs As ADODB.Recordset

Set conDatabase = CurrentProject.Connection

strSQL = "select * from yum_impacter_input" & _
" where dmanumber = " & ex_store_dma & _
" and density = " & ex_density


Set rs = New ADODB.Recordset
rs.Open strSQL, conDatabase

Do While rs.EOF = False
DoCmd.RunSQL "Insert into store_periods( sitenumber, departmentid )
" & _
"values ( '" & recset2.Fields(1) & "', '" &
recset2.Fields(2) & "')"
rs.MoveNext
Loop

rs.Close
conDatabase.Close
End Sub
 
S

Sylvain Lafontaine

Display the sql string in a message box (msgbox) to make sure that either
ex_store_dma and ex_density are not empty or null.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Invalid use of New Keyword 1
Select Stament 2
VBA HELP 1
Treeview Control 0
Problem with some replace code 2
update table records from form 6
ADODB.Recordset 6
error with my ADO code! 2

Top