Stop TAB from entering new record

cochese

Registered User.
Local time
Today, 04:26
Joined
Feb 5, 2008
Messages
54
For the record, I have gone to the form's properties, under Other and Cycle and set it to Current Record. This allows the user to tab around the form, HOWEVER when all fields are entered and the user tabs around it enters the data as a new record and still allows them to tab around.

I want my users to be able to tab around and a new record is not entered until they hit the submit button (which I have and is working).

Perplexed.
 
Do you have a sub form? If yes, when the user moves into the sub form the parent record is automatically saved.
 
you do have to jump through hoops to PREVENT access auto-saving - as there are so many ways to do this.

the only really foolproof way is to use an unbound form, as then there is nothing to auto-save.

the real issue is why you don't want to save the record until you click the button.
 
In design view, set the Allow Additions property to No.

In the Click event of the Submit button you:

* Set the Allow Additions property to Yes
* Create a new record
* Set the Allow Additions property back to No
 
I'll try to respond to all the posts at once.

The form has no sub forms (but does have a footer with a button control in it).

It is crucial that the record not be saved? No, and I doubt anyone would have issue with it, but I do simply because it isn't normal behavior for users (i.e. not expected).

@vbaInet: are you saying to set the form to no additions and then use vba in the on click event of the button control to allow additions then allow the record to be set and then turn additions back off? Can you provide code?

Also, as an aside, I noticed another data entry form I have *does not* add the record as I cycle through! It has not sub form either, and I don't know exactly what I've done differently in it's construction to make it work the way I want. So odd. If you google a solution everything says that setting the Cycle option works, but it doesn't...
 
I'll try to respond to all the posts at once.

The form has no sub forms (but does have a footer with a button control in it).

It is crucial that the record not be saved? No, and I doubt anyone would have issue with it, but I do simply because it isn't normal behavior for users (i.e. not expected).

@vbaInet: are you saying to set the form to no additions and then use vba in the on click event of the button control to allow additions then allow the record to be set and then turn additions back off? Can you provide code?

Also, as an aside, I noticed another data entry form I have *does not* add the record as I cycle through! It has not sub form either, and I don't know exactly what I've done differently in it's construction to make it work the way I want. So odd. If you google a solution everything says that setting the Cycle option works, but it doesn't...

You have proven the Cycle property does work. Something on this form is causing the record to be saved,

Make sure that you do not have some code behind your form that is forcing the save.

I agree that users like to have a save button. All my save buttons do just this:

Code:
' save record if needed
If Me.Dirty Then Me.Dirty = false

That is it. Only one line of code. If I need to do anything else before the record is saved, like validation, I use the form's Before Update event. This way it does not matter how the user saved the record. This event can also be canceled (Cancel = True) so the record is not saved.

The way I would debug this is to place something like this in the form's Before Update event:

Code:
MsgBox "Record is getting saved"
 
are you showing record selectors on the form - they are useful during debugging for stuff like this, as well as general use.

in a dirty record, the black triangle changes to a pencil. if something saves the record, the pencil will change back to a black triangle. (note you can force a save by clicking the triangle/pencil) This may help confirm your thoughts.


thinking again - it must surely be the cycle property - if it's set to currentrecord, it still wouldn't go to the next record. I would check the cycle property carefully. maybe it's modfiied in your code somehwere.


light bulb moment!

re-reading - it isn't going to the next record , is it - it's just staying on the current record, but it's saving it as you tab back to the first field. That must be normnal behaviour. I am not sure how you can stop that.
 
Last edited:
Yes, that is exactly what it is doing. It doesn't move to a new record, what is in the controls stays (I check the table to see if it has been saved). So the user doesn't know the record is saved because all the info is still in the control boxes, but it has been saved.

The one form I have that doesn't add the record has several things different about it, but the main is probably that there is no footer with a button on it...the button is on the main body (i.e. detail) of the form. It's maddening.

It' isn't code, because the ONLY code I have in either form is the a requery and code making some form controls populated by an open form (Ycontrol = Xcontrol from open form stuff).

MADDENING.
 
Yes, that is exactly what it is doing. It doesn't move to a new record, what is in the controls stays (I check the table to see if it has been saved). So the user doesn't know the record is saved because all the info is still in the control boxes, but it has been saved.

The one form I have that doesn't add the record has several things different about it, but the main is probably that there is no footer with a button on it...the button is on the main body (i.e. detail) of the form. It's maddening.

It' isn't code, because the ONLY code I have in either form is the a requery and code making some form controls populated by an open form (Ycontrol = Xcontrol from open form stuff).

MADDENING.

Requery? A form requiry can cause the record to be saved.


Did you try trapping the save with the form's before update event?

The way I would debug this is to place something like this in the form's Before Update event:

Code:
MsgBox "Record is getting saved"
 
I haven't had a chance to do the test, but I will.

Btw, the requery is only activated on the clicking of a button, so how can that be the culprit? The form that is working as I need has a requery line of code too!
 
The best thing is to upload your db and we'll have a look.
 
Here you go. I appreciate this.

The form that doesn't add a record when you cycle through is "frmInfraction" which is launched by using "frmMgrSearch_M". The form that *does* add the record as you cycle through is "frmAddEmployee".
 

Attachments

I downloaded your copy and ran it and I could hold my tab key down and tab through over and over and over again and it never once went to a new record until I clicked the save button.
 
I checked this many times before I posted this thread. I'm typing this from my phone and can't check until tomorrow.

Cycling through does not go to a new record (what is in the textboxes stays) but if you look in the tblEmployees table the new record is there. And in the frmInfraction you can tab forever and a record is never added to the tblDisciplines.

Or so I swear was happening!
 
... but if you look in the tblEmployees table the new record is there.
You would imagine this is what we had done.

Just downloaded your db on another machine, tested it and nothing gets added.
 
attachment.php
 

Attachments

  • cochesetabproblem.png
    cochesetabproblem.png
    11.4 KB · Views: 1,552

Users who are viewing this thread

Back
Top Bottom