Ctrl-V to text box locks up SQL statement in code?

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
 
A

Alicia

I should mention that it's a shared database used through
a network. But the error happens when I have it on my
hard drive also. It seems like the error is not
happening everytime, that's why I'm so puzzled.
 
A

Alicia

I found something that might help me at...
http://www.mcse.ms/message756698.html
-----Original Message-----
I should mention that it's a shared database used through
a network. But the error happens when I have it on my
hard drive also. It seems like the error is not
happening everytime, that's why I'm so puzzled.
-----Original Message-----
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
.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top