Adding Records Only On Button Click?

Ksan

Flailling in the dark
Local time
Today, 16:48
Joined
Oct 26, 2005
Messages
36
Adding Records Only On Button Click?

I am building a database with a single table of records. I have created a form to allow new entries to be made to the table in a user-friendly way.

The problem I’m stuck with is how do I restrict the addition of new records on the form? I want the new record to only be added to the table upon the click of a button, but at present if I tab through, or exit the form the record is saved anyway.

Not all fields on the form are required input so I’m thinking that validation of every field is not the way to go.

I only ever want the record to be saved if a user clicks on a button and under no other circumstance.

I've been trawling through the posts back to about page 15 so any help would be appreciated.

Ksan
 
This question has been answered many times. The basic solution is to create a form level variable that will be used to indicate whether or not the button has been pressed.

You then need to set the button in the Current event and in the Click event of your Button and check it in the BeforeUpdate event. In the BeforeUpdate event, if the buttonClick variable is False, you would Cancel the update with:
Cancel = True
and display an appropriate message.

One post that covers this in a different manor is called "a better mousetrap". You can search for it.
 
Nice one. Fingers crossed I should be able to make a start from that.

Many thanks

Ksan
 
I've got a sample here that deals with adding records only when the ADD button is pressed. It also demonstrates how to deal with confirming edits to controls (bound to a field) and the entire record.

Link to sample is at the end of the article.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom