Dirty Form

G

Guest

I have a command button on my main form (frm_New_Inv) which allows the suer
to toggle between two sub forms (sub_Inv_Details & Sub_Misc_exp). When the
form opens, Sub_Inv_Details is the default sub form and I would like to
prevent the user, via a message, from switching to Sub_Misc_Exp if no data
has been entered on the sub_Inv_details form.

The following code fails to recognize that sub_Inv_details is dirty

With Me.sub_Inv_Details
.SetFocus
End With

If Me.Dirty Then
GoTo Continue
Else
Exit Sub
End If
Continue:

Any and all suggestions are appreciated.
 
G

Guest

Hi Rafi,

I go about it from a slightly different angle - I disable the subform when
you are on a new record. In the form current event for your main form, have
something like this:

if isnull(me.lngRECORDID) then
' no ID = new record
me.SUBFORMNAME.form.enabled = false
else
' have a record
me.SUBFORMNAME.form.enabled = true
endif

Then in the before insert event, remember to set the subform to enabled.

Hope this helps.

Damian.
 
G

Guest

Damian,

Thanks for the reply. I saw that you are making reference to Me.lngRECORDID
and I was wondering if that is something you have defined elsewhere? I also
wanted to add that both my sub forms are continuous forms with potentially
multiple records.

Thanks
 
G

Guest

Hi Rafi,

lngRECORDID is the name of the field that is storing the primary key for
your record - whatever this happens to be named for your data.

Damian.
 

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