AllowEdit problem

E

Emergency Power

I have a menu that opens up a customers form. In vb "on Open" or "on
current" I code:

txtCompany.SetFocus
Form_frmPos2.AllowEdits = False

I can still edit when I open the form. If a navigate to another record,
then I can not edit until I use my edit button, which is what I want.
What am I doing wrong?

Thank you for any help!
 
D

Dirk Goldgar

Emergency Power said:
I have a menu that opens up a customers form. In vb "on Open" or "on
current" I code:

txtCompany.SetFocus
Form_frmPos2.AllowEdits = False

I can still edit when I open the form. If a navigate to another record,
then I can not edit until I use my edit button, which is what I want.
What am I doing wrong?


Probably you have code that dirties the record, even before you set
AllowEdits. Maybe you assign an initial value to some bound control. Once
the current record is dirty, setting AllowEdits to False won't prevent
further edits to that record.

Note: instead of:
Form_frmPos2.AllowEdits = False

.... use

Me.AllowEdits = False

(that is, assuming that this code is running on form "frmPos2"). The
keyword "Me" refers to the form or object in which the code is running.
Also, in general the syntax "Form_FormName" is a bad idea, even when you
need to refer to some other form instead. Use Forms!FormName or
Forms("FormName") instead.
 
D

Dirk Goldgar

Emergency Power said:
Does it matter that I am on a tab "tabClient"?


Only if the form you are trying to lock edits on is actually on a subform of
the main form. The tab control itself is irrelevant, but the subform vs.
main form distinction is important.
 

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