A
Alicia
I have a text box on a form. Everytime someone updates
the text box I do two things 1. create a new record in a
notes history table and 2. update the existing record in
the main table.
The code that I use is below.
For some reason, when ever I use Ctrl-V to paste some
text into the note, the code does not run. I get the
error message Number 2486, "You can't carry out this
action at the present time."
Once I get the error message, I keep getting it over and
over when trying to use other events (like your basic
close button that my code just tells to close the form)
and then I have to force the database application to
close sometimes from the task manager.
Private Sub txtNote_AfterUpdate()
On Error GoTo Err_txtNote_AfterUpdate
'store the note and time stamp in a table for notes
history tracking
Dim strSQL As String
strSQL = "INSERT INTO tblNoteHist ( fldChannel,
fldItem, fldTimeStamp, " & _
"fldNote ) SELECT [Forms]![frmTools]!
[txtChannel], " & _
"[Forms]![frmTools]![txtItem], #" & _
Now & "#, [Forms]![frmTools]![txtNote]"
'DoCmd.SetWarnings (False)
DoCmd.RunSQL strSQL
'DoCmd.SetWarnings (True)
'want to add an update statement for tblMain
strSQL = "UPDATE tblMain SET fldNote = " & _
"[Forms]![frmTools]![txtNote] WHERE " & _
"(((tblMain.fldChannel) = [Forms]!
[frmTools]![txtChannel]) AND " & _
"((tblMain.fldItem) = [Forms]![frmTools]!
[txtItem]))"
'DoCmd.SetWarnings (False)
DoCmd.RunSQL strSQL
'DoCmd.SetWarnings (True)
Exit_txtNote_AfterUpdate:
Exit Sub
Err_txtNote_AfterUpdate:
MsgBox "Error Number: " & Err.Number & ". " &
Err.Description
Resume Exit_txtNote_AfterUpdate
End Sub
the text box I do two things 1. create a new record in a
notes history table and 2. update the existing record in
the main table.
The code that I use is below.
For some reason, when ever I use Ctrl-V to paste some
text into the note, the code does not run. I get the
error message Number 2486, "You can't carry out this
action at the present time."
Once I get the error message, I keep getting it over and
over when trying to use other events (like your basic
close button that my code just tells to close the form)
and then I have to force the database application to
close sometimes from the task manager.
Private Sub txtNote_AfterUpdate()
On Error GoTo Err_txtNote_AfterUpdate
'store the note and time stamp in a table for notes
history tracking
Dim strSQL As String
strSQL = "INSERT INTO tblNoteHist ( fldChannel,
fldItem, fldTimeStamp, " & _
"fldNote ) SELECT [Forms]![frmTools]!
[txtChannel], " & _
"[Forms]![frmTools]![txtItem], #" & _
Now & "#, [Forms]![frmTools]![txtNote]"
'DoCmd.SetWarnings (False)
DoCmd.RunSQL strSQL
'DoCmd.SetWarnings (True)
'want to add an update statement for tblMain
strSQL = "UPDATE tblMain SET fldNote = " & _
"[Forms]![frmTools]![txtNote] WHERE " & _
"(((tblMain.fldChannel) = [Forms]!
[frmTools]![txtChannel]) AND " & _
"((tblMain.fldItem) = [Forms]![frmTools]!
[txtItem]))"
'DoCmd.SetWarnings (False)
DoCmd.RunSQL strSQL
'DoCmd.SetWarnings (True)
Exit_txtNote_AfterUpdate:
Exit Sub
Err_txtNote_AfterUpdate:
MsgBox "Error Number: " & Err.Number & ". " &
Err.Description
Resume Exit_txtNote_AfterUpdate
End Sub