Form Command Buttons

R

Roachina

Hello,

I have a bound data entry form that opens up blank (to a new record). On
this form, I have 6 command buttons (add, undo, find, edit, delete, save). I
do not want the user to be able to enter any data into the blank form fields
until he clicks one of these command buttons. How can I accomplish this?

Thank you for your time.
 
K

Klatuu

Your request doesn't seem logical. Lets look at the buttons.
add - No need to do this, you are already on a new record.
undo - Undo what? nothing has bee entered to undo.
find - What would you want to find? If this were not a data entry form, it
would make sense.
edit - There is nothing to edit. You haven't entered anything yet.
delete - Why would you want to delete a new record with nothing it in?
save - There is nothing to save.

If your form was not a data entry form, then your buttons would make sense.
 
R

Roachina

Hello Mr. Hargis,

Thank you for responding. I'm a bit new at this, so I apologize if my
request was seemed illogical. Let me start over.

I have a form that is bound to a table. What I want is for the form to open
up blank (I didn't know how to do this without going to a new record). I do
not want the user to be able to enter anything into the fields until first
clicking the "Add" or "Find" command buttons.

If clicking "Add" (which means he will add a new record), the use will enter
data which will be added to the table ONLY upon clicking the "Save" button.
If the "Save" button is not clicked, I do not want the table updated with the
information. Also, if there is a problem with his data entry, he can click
the "Undo" button prior to clicking "Save".

If clicking "Find", the "Find/Replace" window will come up allowing the user
to search the table for a certain record based on data that he enters, with
the data being displayed on the form. He can then:

1) click the "Edit" button to edit this record, then click the "Save" button
to save it to the table. I do not want the information updated unless the
"Save" button is clicked.

Or

2) click the "Delete" button to delete the record.

I've designed my form and have my table. I have my buttons basically
working, but there are some aspects of my form that don't do what I want them
to do. So first of all, I need my form to open up BLANK and NON-EDITABLE
until the "Add" or "Find" buttons are clicked. How can I do this?

I apologize for being so long-winded. I appreciate your time.
 
K

Klatuu

You can do what you want to do, but the phylosophy of your form design makes
your work harder and will be frustrating for users to use. It really is
better to just allow the form to open to the first record in the form's
recordset as it normally does. The add, find, delete, and undo buttons are
all very useful, but a save button to work as you want it to takes more
coding than perhaps you are aware of.

Any time you move to a different record or close the form, the current
record is automatically saved. This really makes it easier for the user. To
ensure the user has entered valid data, the normal approach is to use the
form's Before Update event to validate all the entried in the control and if
incorrect entried are detected, notify the user with a message box and cancel
the update.

So, the short of it is, I would advise you to rethink your form design.
But, to answer your question, you can use the Form's Allow Edits property to
control whether any editing will be allowed. You do that with:

Me.AllowEdits = True (or False)

Depending, of course on the pressing of a button or some other action. The
controlling of the save button is the hard part. To save the record, you can
use:

If Me.Dirty = True Then
Me.Dirty = False
End If

The problem here is that if you use that and you cancel the form before
update event, it will throw an error. Also, you have to code for a user
moving to a different record or closing the form without first clicking your
save button. That is a tricky bit of work.
 
R

Roachina

This is my first attempt at creating a form to update a table, so your input
is much appreciated. I will definitely re-think my form design to find the
simplest way to accomplish my task. Thank you again for your time.
 

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