R
Rachel Garrett
I am trying to use SQL to update two tables based upon the user
updating a value in a form. One is working; when the user changes a
value, the value in the table changes appropriately. With the second
SQL statement, nothing seems to happen. The difference is that I am
using an INSERT statement in for the one that doesn't work. Can anyone
tell me if there is something wrong with the following syntax?
Private Sub Milestone_1_target_date_AfterUpdate()
'mySQL2 appends historical information to [Record of Target Date
Changes]
Dim mySQL2 As String
Dim myAssessmentDate As String
myAssessmentDate = Format(Date, "MM/DD/YYYY")
mySQL2 = "INSERT INTO [Record of Target Date Changes]"
mySQL2 = mySQL2 + " ( [QNameMilestoneAssmDate], [Question Name],
[Milestone], [Target date pre-assessment], "
mySQL2 = mySQL2 + "[New target date after assessment], [Assessment
date] )"
mySQL2 = mySQL2 + " VALUES ('TestingKey', 'Testing QName', 1, "
'1/1/2020 is dummy data for testing purposes.
mySQL2 = mySQL2 + "#1/1/2020#, #" + myString
mySQL2 = mySQL2 + "#, #" + myAssessmentDate + "# 1/1/2020# )"
'Hide VB's automatic warning messages about running SQL on a button
click
DoCmd.SetWarnings False
DoCmd.RunSQL mySQL2
'Re-enable warnings after SQL is done running
DoCmd.SetWarnings True
End Sub
updating a value in a form. One is working; when the user changes a
value, the value in the table changes appropriately. With the second
SQL statement, nothing seems to happen. The difference is that I am
using an INSERT statement in for the one that doesn't work. Can anyone
tell me if there is something wrong with the following syntax?
Private Sub Milestone_1_target_date_AfterUpdate()
'mySQL2 appends historical information to [Record of Target Date
Changes]
Dim mySQL2 As String
Dim myAssessmentDate As String
myAssessmentDate = Format(Date, "MM/DD/YYYY")
mySQL2 = "INSERT INTO [Record of Target Date Changes]"
mySQL2 = mySQL2 + " ( [QNameMilestoneAssmDate], [Question Name],
[Milestone], [Target date pre-assessment], "
mySQL2 = mySQL2 + "[New target date after assessment], [Assessment
date] )"
mySQL2 = mySQL2 + " VALUES ('TestingKey', 'Testing QName', 1, "
'1/1/2020 is dummy data for testing purposes.
mySQL2 = mySQL2 + "#1/1/2020#, #" + myString
mySQL2 = mySQL2 + "#, #" + myAssessmentDate + "# 1/1/2020# )"
'Hide VB's automatic warning messages about running SQL on a button
click
DoCmd.SetWarnings False
DoCmd.RunSQL mySQL2
'Re-enable warnings after SQL is done running
DoCmd.SetWarnings True
End Sub