I have a form that I added a command button to. If the Data_Start is populated then I need to update data in a table.
Here is the code:
Private Sub AddIntakeGoals_Click()
On Error GoTo Err_AddIntakeGoals_Click
Dim db As Database
Set db = CurrentDb
If (Me!Date_Start) Is Not Null Then
Dim MyDate As Date
Dim strSQL As String
Dim strTrGoal As String
Dim strGoalA As String
Dim strGoalB As String
MyDate = Date
strTrGoal = "To participate in the therapeutic process"
strGoalA = "Client will complete intake paperwork including completing a social history"
strGoalB = "Client will assist therapist in developing at least one individualized treatment goal"
strSQL = "INSERT INTO tblGoal (GoalIDStaff,Treatment_Goal, " _
& " GoalA,GoalB,Goal_Number,GoalA_Date,GoalB_Date,Updated) " _
& " SELECT tblGoalStaff.GoalIDStaff, " _
& " strTrGoal As Treatment_Goal, " _
& " strGoalA As GoalA, " _
& " strGoalB As GoalB, " _
& " 1 As Goal_Number, #" & MyDate & "# As GoalA_Date, " _
& " #" & MyDate & "# As GoalB_Date, #" & MyDate & "# As Updated " _
& " FROM (tblGoal inner join tblGoalStaff on tblGoal.GoalIDStaff = tblGoalStaff.GoalIDStaff)"
CurrentDb.Execute strSQL, dbFailOnError
End If
Exit_AddIntakeGoals_Click:
Exit Sub
Err_AddIntakeGoals_Click:
MsgBox Err.Description
Resume Exit_AddIntakeGoals_Click
End Sub
I keep getting an object required Access error message. Also when I tested this without the Date_Start it updated all records in my table not just the current record like I need. Luckily I am in a test database. I am down to the wire on this. Any help would be really appreciated.
Here is the code:
Private Sub AddIntakeGoals_Click()
On Error GoTo Err_AddIntakeGoals_Click
Dim db As Database
Set db = CurrentDb
If (Me!Date_Start) Is Not Null Then
Dim MyDate As Date
Dim strSQL As String
Dim strTrGoal As String
Dim strGoalA As String
Dim strGoalB As String
MyDate = Date
strTrGoal = "To participate in the therapeutic process"
strGoalA = "Client will complete intake paperwork including completing a social history"
strGoalB = "Client will assist therapist in developing at least one individualized treatment goal"
strSQL = "INSERT INTO tblGoal (GoalIDStaff,Treatment_Goal, " _
& " GoalA,GoalB,Goal_Number,GoalA_Date,GoalB_Date,Updated) " _
& " SELECT tblGoalStaff.GoalIDStaff, " _
& " strTrGoal As Treatment_Goal, " _
& " strGoalA As GoalA, " _
& " strGoalB As GoalB, " _
& " 1 As Goal_Number, #" & MyDate & "# As GoalA_Date, " _
& " #" & MyDate & "# As GoalB_Date, #" & MyDate & "# As Updated " _
& " FROM (tblGoal inner join tblGoalStaff on tblGoal.GoalIDStaff = tblGoalStaff.GoalIDStaff)"
CurrentDb.Execute strSQL, dbFailOnError
End If
Exit_AddIntakeGoals_Click:
Exit Sub
Err_AddIntakeGoals_Click:
MsgBox Err.Description
Resume Exit_AddIntakeGoals_Click
End Sub
I keep getting an object required Access error message. Also when I tested this without the Date_Start it updated all records in my table not just the current record like I need. Luckily I am in a test database. I am down to the wire on this. Any help would be really appreciated.