By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,392 Members | 1,556 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,392 IT Pros & Developers. It's quick & easy.

Sql String got error ?

P: n/a
Hi all , its the first time for me to execute an SQL statment from
within a command in MS access VB form. I havnt added to runSql command
yet. But i get and error pointing to the first line of my method and
the string is in red font .

Is there something wrong in the syntax of the string . or Am i supposed
to put such statments in a macro or a method not in an underlying
form's code page ?

Regards
Private Sub QualifyLeaveCmd_Click()

Dim stDocName As String
Dim strSQL As String

'Check Is Approved Button
'Set is_approved.Value = 0
Me.is_approved.Value = 0
'Save this leaveDetails
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70

'Update Credit

strSQL = "Update initial_credit " &_
" Set initial_credit ="& Me.credit2 &", idate='"& Now() &"'" &_
" WHERE employee_id=" & Me.Combo63.Value

End Sub

Dec 6 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"First line of your method"?

Which line do you consider "first" -- Private Sub QualifyLeaveCmd_Click()
or DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70 (the first uncommented like of executable code), or the line
where you set the SQL statement?

Just a comment... you are surrounding the data/time returned by Now() with
single quotes '. Dates are delimited by # not '.

Larry Linson
Microsoft Access MVP

Dec 6 '06 #2

P: n/a
al******@gmail.com wrote:
Hi all , its the first time for me to execute an SQL statment from
within a command in MS access VB form. I havnt added to runSql command
yet. But i get and error pointing to the first line of my method and
the string is in red font .

Is there something wrong in the syntax of the string . or Am i supposed
to put such statments in a macro or a method not in an underlying
form's code page ?

Regards
Private Sub QualifyLeaveCmd_Click()

Dim stDocName As String
Dim strSQL As String

'Check Is Approved Button
'Set is_approved.Value = 0
Me.is_approved.Value = 0
'Save this leaveDetails
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70

'Update Credit

strSQL = "Update initial_credit " &_
" Set initial_credit ="& Me.credit2 &", idate='"& Now() &"'" &_
" WHERE employee_id=" & Me.Combo63.Value

End Sub
You are missig a space between the ampersand and the line continuation
sign in addition to issues with the date formatting - air code
amendments

strSQL = "Update initial_credit " & _
" Set initial_credit =" & Me.credit2 &", idate=#" & _
format$(Now(), "yyyy-mm-dd hh:nn:ss") & "#" & _
" WHERE employee_id=" & Me.Combo63.Value

Dec 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.