I keep getting a syntax error on This lline Call rs.Open(strsql, strConnectionString)
for my strsql string My string equals "INSERT INTO Usage (eDates) Values (#05/06/2011#);"
My access Data base Edates is set to be a date/time value. Does anyone know what I am doing wrong?
public counta as integer
Sub Insertinga()
'stay
counta = 4
While Range("a" & counta) <> ""
Application.Run ("senddata")
counta = counta + 1
Wend
End Sub
Sub senddata()
Dim rs As Recordset
Set rs = New Recordset
Dim n As Date
Dim edates As Date
Dim etimes As Date
Dim Peak As String
Dim KWh As Double
Dim KWd As Double
Dim KWa As Double
Dim KVar As Double
Dim PF As Double
edates = Range("h" & counta)
etimes = Range("i" & counta)
emonths = Range("j" & counta)
Peak = Range("b" & counta)
KWh = Range("c" & counta)
KWd = Range("d" & counta)
KWa = Range("e" & counta)
KVar = Range("f" & counta)
PF = Range("g" & counta)
'strsql = "INSERT INTO Usage (Dates, Times, Peak, KWh, Kwd, KVa, KVar, PF, Months) VALUES (" & "#" & dates & "#, #" & times & "#, " & Peak & ", " & KWh & ", " & KWd & ", " & KVa & ", " & KVar & ", " & PF & ", #" & edates & "#);"
strsql = "INSERT INTO Usage (eDates) Values (#" & edates & "#);"
'Adjust Filepath to Access in this string as needed
Const strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & _
"\\pvnt2\home\Manufacturing\JWallace\Accessdatabases\Energyusage.mdb" & _
";Persist Security Info=False"
Call rs.Open(strsql, strConnectionString)
'rs.MoveFirst 'Header
'rs.MoveNext 'Actual first record
If (rs.State And ObjectStateEnum.adStateOpen) Then rs.Close
If Not rs Is Nothing Then Set rs = Nothing
End Sub
for my strsql string My string equals "INSERT INTO Usage (eDates) Values (#05/06/2011#);"
My access Data base Edates is set to be a date/time value. Does anyone know what I am doing wrong?
public counta as integer
Sub Insertinga()
'stay
counta = 4
While Range("a" & counta) <> ""
Application.Run ("senddata")
counta = counta + 1
Wend
End Sub
Sub senddata()
Dim rs As Recordset
Set rs = New Recordset
Dim n As Date
Dim edates As Date
Dim etimes As Date
Dim Peak As String
Dim KWh As Double
Dim KWd As Double
Dim KWa As Double
Dim KVar As Double
Dim PF As Double
edates = Range("h" & counta)
etimes = Range("i" & counta)
emonths = Range("j" & counta)
Peak = Range("b" & counta)
KWh = Range("c" & counta)
KWd = Range("d" & counta)
KWa = Range("e" & counta)
KVar = Range("f" & counta)
PF = Range("g" & counta)
'strsql = "INSERT INTO Usage (Dates, Times, Peak, KWh, Kwd, KVa, KVar, PF, Months) VALUES (" & "#" & dates & "#, #" & times & "#, " & Peak & ", " & KWh & ", " & KWd & ", " & KVa & ", " & KVar & ", " & PF & ", #" & edates & "#);"
strsql = "INSERT INTO Usage (eDates) Values (#" & edates & "#);"
'Adjust Filepath to Access in this string as needed
Const strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & _
"\\pvnt2\home\Manufacturing\JWallace\Accessdatabases\Energyusage.mdb" & _
";Persist Security Info=False"
Call rs.Open(strsql, strConnectionString)
'rs.MoveFirst 'Header
'rs.MoveNext 'Actual first record
If (rs.State And ObjectStateEnum.adStateOpen) Then rs.Close
If Not rs Is Nothing Then Set rs = Nothing
End Sub