Link to home
Start Free TrialLog in
Avatar of Jenkins
JenkinsFlag for United States of America

asked on

Table Bound to a Form - MS Access

I have an Access database with a bound form.   The form is used for adding records to a table. It has a bunch of textboxes and comboboxes on it for data entry. After the user enters required data into the boxes, (s)he clicks a command button to add a record.

Currently, when the form is opened, the boxes are populated with data from the first record in the table.  I do not want this.  I want all boxes to be empty upon opening/activating the form. How can I accomplish this?
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Set the Form Data Entry property to Yes.
This will allow only adding New Records ...and open the Form to a blank, new record.
Avatar of Jenkins

ASKER

But wait.  I'm going to be using the form to allow the user to scroll through already-entered records to update or delete them if they so choose. Your comment says setting it that way will only allow New Records.
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jenkins

ASKER

Causes an error on the Load and Activate events but works on the Open event. I'll take it! Thanks.
Private Sub Form_Load()
    On Error Resume Next
    DoCmd.RunCommand acCmdRecordsGoToNew
    On Error Goto To 0  'reset
End Sub

You could ... put in more error handling here, but this covers the two cases above.
Another option is to make a record with all blank values (or dummy values), if you can get the key field to be first in the order of the form's record source.  This can be useful if you have users who tend to open a form and start typing in it, without first selecting the appropriate record.