Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enabling/Disabling Buttons not working

Status
Not open for further replies.

TheFitz

Programmer
Dec 18, 2003
140
GB
I have an Edit Only form (AllowAdditions property = no) with a button to switch it to data entry (See code sample 1). It also makes a button (cmdEsc) visible which returns the form to Edit only (see Code sample 2). cmdEsc has the 'Cancel' property set to true (allowing the user to hit escape to switch from Data Entry to Edit Only). The form is operating as a subform of the master control panel.
When 'cmdEsc' is clicked, the code works perfectly, but when escape is pressed, the form blanks, as if I'd only switched the DataEntry property off.
If I attempt to step through the code, it works perfectly, if I put a debug.print at the end of code sample 2, then that proves that both AllowAdditions and DataEntry are set to 'False'.
I can work around by either reloading the form after resetting the properties, or by putting a 'DoEvents' in after the 'Me.AllowAddition = False' line. But I can't quite figure out why this is happening - any thoughts?

Code Sample 1
Code:
    Me.AllowAdditions = True 
    Me.DataEntry = True 
    Me.cmdEsc.Visible = True
Code Sample 2
Code:
    Me.AllowAdditions = False 
    Me.DataEntry = False 
    Me.cmdEsc.Visible = False

Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!
 

I've been reading this post for two days now and still don't understand exactly what you mean; probably a result of the cough medication I'm taking.

But first, you don't need to have AllowAdditions and Data Entry both set to Yes. Data Entry will override whatever AllowAdditions is set to. You don't need Data Entry set to Yes, BTW, in order to enter data. Data Entry set to Yes means you can only enter new records. You can enter new records with just AllowAdditions set to Yes.

If by
but when escape is pressed, the form blanks[/code]
you mena when the <Escape> key is pressed, that's because <Escape> is a standard Access keyboard shortcut to do just that. Pressing <Escape> once undoes or deletes data just entered from the current textbox; pressing it twice undoes all unsaved changes made to the record.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
It doesn't seem to work that way for me, if I have AllowAdditions set to False and DataEntry set to True then the form gives me no records AND no new entry. Yes I am aware that DataEntry only allows you to enter records - this is what I want.

To clarify what I'm saying re: the escape key:

I'm in data entry mode, cmdEsc is visible (meaning that the 'Cancel' property of the button is active, diverting the escape key to this button. At this point there is only the data entry 'record' (for want of a better term) displaying on the form, so no new records have been started. If I hit Escape at this point, then the data entry 'record' disappears and the already entered records do not reappear - when I say a blank screen, I mean that it has nothing but the form header there, no data entry boxes, no records displaying, no nothing (thisdoesn't appear to me to be the normal behaviour of the Escape key). If, however, I click the cmdEsc button is clicked, then the data entry 'record' disappears, to be replaced by the records which have been previously entered on the form.

Hope this helps clarify what I going on about.

Cheers.

Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top