using a form to add a record to table

complexx

Registered User.
Local time
Today, 06:49
Joined
Dec 15, 2005
Messages
64
I have a table of information. I have created a form to input all the data necessary in order to add a record to the table. The form is not currently based off of the table and is simply a bunch of text boxes with labels.

The reason why I didn't create the form based off the table is because I don't want all the contents of the table to be displayed when the form is loaded. I want to form to be soley for adding new records to the table. I also don't want the form to display any information from the table when it loads, I want it blank. I don't want any chance of the person that is using the form to be confused or accidentally be able to edit the data in the table.

I have added a button that I want to use to initiate adding the new record.

How can I now retrieve all the data in the textboxes and use that to add a new record to the table. Is there simply a few lines of code that can do this that I can add to the on_click of the button?
 
You can open a form in different modes. If you set the form to data entry, this will allow the user to enter data only, and the existing records are not visible. You can then bind this form to the table. This is a lot simpler than using an unbound form and VBA code.
 
That seems to work nicely, thanks for the help.

One question. When I want to delete a record, I use the same idea of a form with no data entry and allow deletions, however when I delete all the data fields, the record is not delete, it is just erased, is there a way to have the record be completely removed from the table?
 
Mmm...

When you delete a record in a table, Access doesn't free up that space until you do a Compact & Repair. However, I don't think you are talking about that. If you are deleting the data in the individual fields, then this doesn't delete the record, you just get a record with no data. The command button wizard will help you to build a routine that will actually delete the record.
 

Users who are viewing this thread

Back
Top Bottom