G
gsnidow via AccessMonster.com
Greeting folks. I have a form, frmSearchEWO, that has an unbound text box
where users can type a note, then hit a button, and save it, which will also
save the primary key of the current record. The on close event of the form
is as follows, and is to make people either save it, or delete it.
If Len("" & Me.txtAddNote) > 0 Then
If MsgBox("Your note will be lost if you do not save. Do you want to
save it", vbYesNo, "Text Box") = vbYes Then
Me.cmdAddNote.SetFocus
End If
End If
Basically, the only way I could think of to do it was to look at the length
of the field, and prompt to save if it is greater than 0. The problem is
that if people simply search for another record, using a search popup,
frmSearchPopup, when frmSearchEWO requeries, it does not prompt to save the
note, so people will have pulled up another record with an unsaved note from
the last record. Then, when they close the form they are prompted to save,
which they do, but it is getting saved to the new record. I put got focus
event behind the search popup, as follows
If Len("" & Forms!frmSearchEWO!txtAddNote) > 0 Then
If MsgBox("Your note will be lost if you do not save. Do you want to
save it", vbYesNo, "Text Box") = vbYes Then
Forms!frmSearchEWO!cmdAddNote.SetFocus
End If
End If
I basically changed the Me.txtAddNote to Forms!frmSearchEWO!txtAddNote,
hoping that it would reference the main open form, but nothing happens when
the search popup gets the focus. Any ideas?
Greg
where users can type a note, then hit a button, and save it, which will also
save the primary key of the current record. The on close event of the form
is as follows, and is to make people either save it, or delete it.
If Len("" & Me.txtAddNote) > 0 Then
If MsgBox("Your note will be lost if you do not save. Do you want to
save it", vbYesNo, "Text Box") = vbYes Then
Me.cmdAddNote.SetFocus
End If
End If
Basically, the only way I could think of to do it was to look at the length
of the field, and prompt to save if it is greater than 0. The problem is
that if people simply search for another record, using a search popup,
frmSearchPopup, when frmSearchEWO requeries, it does not prompt to save the
note, so people will have pulled up another record with an unsaved note from
the last record. Then, when they close the form they are prompted to save,
which they do, but it is getting saved to the new record. I put got focus
event behind the search popup, as follows
If Len("" & Forms!frmSearchEWO!txtAddNote) > 0 Then
If MsgBox("Your note will be lost if you do not save. Do you want to
save it", vbYesNo, "Text Box") = vbYes Then
Forms!frmSearchEWO!cmdAddNote.SetFocus
End If
End If
I basically changed the Me.txtAddNote to Forms!frmSearchEWO!txtAddNote,
hoping that it would reference the main open form, but nothing happens when
the search popup gets the focus. Any ideas?
Greg