Wrote this code about a year ago and worked fine up until last week. I do not use access or vba daily so this problem maybe something very easy but I tried a lot of things and am kind of stumped. I have a table (tbl_classes) which contains all upcoming and completed classes, the difference is if a checkbox has been checked it is completed. So now there is a query that looks at only the uncompleted classes (looks for a null in the checkbox field) and shows them on a subform. When the class gets completed the user will click the checkbox on the subform which runs the code below.
Private Sub Completed__Click()
Dim strCompDate As String
If MsgBox("Has This Been Completed?", vbYesNo) = vbYes Then
Do
strCompDate = InputBox("Enter completion date:", "Completion Date?",
Format(Now(), "Short Date"))
If strCompDate = "" Then Me.Completed_.Value = False
If strCompDate = "" Then MsgBox "GoodBye"
If strCompDate = "" Then Exit Sub
If IsDate(strCompDate) = False Then MsgBox "Incorrect date format -- please re-enter!!"
Loop Until IsDate(strCompDate)
If Me.Dirty Then Me.Dirty = False
DoCmd.RunSQL ("UPDATE tbl_classes SET tbl_classes.completeddate = #" & strCompDate & "# WHERE tbl_classes.course = ' " & Me.Course & " ' ")
Else
Me.Completed_.Value = False
End If
End Sub
All I'm looking for it to do is place the date they had entered into the msgbox into the tbl_classes.completeddate field but for some reason, I am not entirely sure what I changed, it has stopped working. I set watches on the strComp date and Me.Course and both return the correct values. I changed the WHERE tbl_classes.course = to WHERE tbl_classes.course <> and it does change all of the records in the table so it seems to me like the tbl_classes.course does not equal the Me.course which does not make sense to me because this subform is just showing data from the tbl_classes and the course name is not changed in any way. Again this may be a no brainer but just looking for some ideas, I appreciate any help. Thanks.
Private Sub Completed__Click()
Dim strCompDate As String
If MsgBox("Has This Been Completed?", vbYesNo) = vbYes Then
Do
strCompDate = InputBox("Enter completion date:", "Completion Date?",
Format(Now(), "Short Date"))
If strCompDate = "" Then Me.Completed_.Value = False
If strCompDate = "" Then MsgBox "GoodBye"
If strCompDate = "" Then Exit Sub
If IsDate(strCompDate) = False Then MsgBox "Incorrect date format -- please re-enter!!"
Loop Until IsDate(strCompDate)
If Me.Dirty Then Me.Dirty = False
DoCmd.RunSQL ("UPDATE tbl_classes SET tbl_classes.completeddate = #" & strCompDate & "# WHERE tbl_classes.course = ' " & Me.Course & " ' ")
Else
Me.Completed_.Value = False
End If
End Sub
All I'm looking for it to do is place the date they had entered into the msgbox into the tbl_classes.completeddate field but for some reason, I am not entirely sure what I changed, it has stopped working. I set watches on the strComp date and Me.Course and both return the correct values. I changed the WHERE tbl_classes.course = to WHERE tbl_classes.course <> and it does change all of the records in the table so it seems to me like the tbl_classes.course does not equal the Me.course which does not make sense to me because this subform is just showing data from the tbl_classes and the course name is not changed in any way. Again this may be a no brainer but just looking for some ideas, I appreciate any help. Thanks.