G
gsnidow via AccessMonster.com
Greetings all. I've got a popup form for adding a note to a notes table. On
the form there is a command button to insert the note then close the add note
form. It works fine when sub fires from the on click event of the button.
However, if I take the same code and put it in the got focus event, I get an
error, shown below after the code. The message is inserted, and the main
form is requeried, bu the add not popup does not close. If I hit ok on the
error message, then hit enter again, the add not popup then closes. My
intention is that the user can simply hit enter after typing the note rather
than having to hit the save button. Below is the code followed by the error.
I am using Access 2003 .ADP. Thank you.
'Code*****************************
Dim strSQL As String
Dim COMP_KEY As String
COMP_KEY = Forms!frmZMMR41_ZZMB52_Main!Child1.Form!txtCompKey.Value
strSQL = "INSERT INTO tblstorekeeper_notes(comp_key,note) " & _
"SELECT '" & COMP_KEY & "', '" & Replace(Me.txtNote, "'", "''")
& "'"
DoCmd.RunSQL strSQL
Forms!frmZMMR41_ZZMB52_Main!Child1.Form.Requery
DoCmd.Close acForm, "frmAddNote"
'Error message*******************
'This action can't be carried out while processing a form or report event.
the form there is a command button to insert the note then close the add note
form. It works fine when sub fires from the on click event of the button.
However, if I take the same code and put it in the got focus event, I get an
error, shown below after the code. The message is inserted, and the main
form is requeried, bu the add not popup does not close. If I hit ok on the
error message, then hit enter again, the add not popup then closes. My
intention is that the user can simply hit enter after typing the note rather
than having to hit the save button. Below is the code followed by the error.
I am using Access 2003 .ADP. Thank you.
'Code*****************************
Dim strSQL As String
Dim COMP_KEY As String
COMP_KEY = Forms!frmZMMR41_ZZMB52_Main!Child1.Form!txtCompKey.Value
strSQL = "INSERT INTO tblstorekeeper_notes(comp_key,note) " & _
"SELECT '" & COMP_KEY & "', '" & Replace(Me.txtNote, "'", "''")
& "'"
DoCmd.RunSQL strSQL
Forms!frmZMMR41_ZZMB52_Main!Child1.Form.Requery
DoCmd.Close acForm, "frmAddNote"
'Error message*******************
'This action can't be carried out while processing a form or report event.