Syntax error?

  • Thread starter Thread starter AJ
  • Start date Start date
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
 
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.
 
Back
Top