R
Rob
Hi all,
I have a question about a text box. When a user checks a particular
check box, a text box is filled with the current date (see below)
If Me!chkTaskStarted.Value = True Then
Me!txtActualStart.Enabled = True
Me!txtActualStart.Value = Format(Date, "dd mmm yy")
Me!chkTaskCompleted.Enabled = True
Else <snip>
End If
This works as expected and the formatted date is displayed. I then need
to run an update on another field on the underlying table, however if
the user does not change the preformatted date I do not catch it with
BeforeUpdate. Should I change the following code to use the OnChange
event instead.
---------------------------------------------
Private Sub txtActualStart_BeforeUpdate(Cancel As Integer)
Dim db As Database
Dim strSQL As String
MsgBox "Am I here?"
Set db = DBEngine(0)(0) ' Set the current database
If CheckDates(Me!txtStartDate, Me!txtActualStart) = False Then
MsgBox "Incorrect or empty start date." etc, etc
Cancel = True
Me.txtActualStart.Undo
End If
'Run a query to update the status of the task and then requery the
combo box
strSQL = "UPDATE tblTasks SET tblTasks.taskStatus = 9 WHERE
((tblTasks.taskID) = " & Me!txtTaskID.Value & ")"
db.Execute (strSQL)
Me!cmbStatus.Requery
Set db = Nothing ' Clean up
End Sub
I have a question about a text box. When a user checks a particular
check box, a text box is filled with the current date (see below)
If Me!chkTaskStarted.Value = True Then
Me!txtActualStart.Enabled = True
Me!txtActualStart.Value = Format(Date, "dd mmm yy")
Me!chkTaskCompleted.Enabled = True
Else <snip>
End If
This works as expected and the formatted date is displayed. I then need
to run an update on another field on the underlying table, however if
the user does not change the preformatted date I do not catch it with
BeforeUpdate. Should I change the following code to use the OnChange
event instead.
---------------------------------------------
Private Sub txtActualStart_BeforeUpdate(Cancel As Integer)
Dim db As Database
Dim strSQL As String
MsgBox "Am I here?"
Set db = DBEngine(0)(0) ' Set the current database
If CheckDates(Me!txtStartDate, Me!txtActualStart) = False Then
MsgBox "Incorrect or empty start date." etc, etc
Cancel = True
Me.txtActualStart.Undo
End If
'Run a query to update the status of the task and then requery the
combo box
strSQL = "UPDATE tblTasks SET tblTasks.taskStatus = 9 WHERE
((tblTasks.taskID) = " & Me!txtTaskID.Value & ")"
db.Execute (strSQL)
Me!cmbStatus.Requery
Set db = Nothing ' Clean up
End Sub