Reference to another form not working

  • Thread starter gsnidow via AccessMonster.com
  • Start date
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
 
D

Dale Fye

Why are you using a search form to add information? Usually, when I use a
separate search form, I'll allow the user to establish search criteria, but
once they have done that, I'll find the record and take them to that record
in my main form, or filter the main form if multiple records that match the
search criteria are found.

Then, If I want them to be able to add notes regarding the record selected,
I'll have a separate textbox on the form, maybe a separate tab, or possibly a
separate form for adding notes.

Alternately, if your search form is bound to the results of your search,
then you could bind the notes textbox to the form.
 
G

gsnidow via AccessMonster.com

Dale
The name of the main form, frmSearchEWO, is misleading, in that it is named
after the parameterized stored procedure, spSearchEWO, that is its' record
source. The issue is why won't the reference to frmSearchEWO work from the
search popup form, frmSearchPopup.
 

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