Solved

Clear Form

Posted on 2014-01-17
4
505 Views
Last Modified: 2014-01-23
I've created a entry/view form.  I would like this form to always come up empty.  So I add this event code

Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub

It doesn't seem to always work.  On the first new input record it seems to works...but after that it doesn't seem to work.  

Any and all comments are welcomed?
0
Comment
Question by:EASCOA
4 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 500 total points
ID: 39790523
You may change the default property in design view: What? Data Entry: Yes

How?
Form properties sheet > Data tab > Data Entry: Yes
0
 
LVL 84
ID: 39792077
When you say "blank record", what exactly are you referring to? Do you want the form to open ready for entering a new record, or do you want the form to open and allow the user to search for an existing record?

-- If you want to open to a new record, then the Data Entry method suggested by hnasr may be the easiest way. Note that this can sometimes cause blank/unfilled/empty records to be recorded in the table, which can be troublesome to deal with, so be sure to also include code to validate the form before it's saved.

-- If you want to allow users to search for an existing record, then set the Form's Recordsource to show no records:

SELECT * FROM MyQueryOrTable WHERE 1=0

This will still "bind" the form, but you could then include controls and code to allow the user to locate a specific record, or to add a new record.
0
 
LVL 15

Expert Comment

by:JimFive
ID: 39794620
The Form_Load() event only occurs when the form is first loaded.

It sounds to me like you are wanting the user to see only the "New" record.  Using Data Entry mode, as suggested above will not show existing records, but will show all of the records that were entered during the current session.

You can use Me.Requery in the vba code of the OnCurrent event to hide the newly entered records.

You could attempt to put the DoCmd.GotoRecord in the OnInsert event, but this can cause problems as Access will sometimes insert the record before you think it should, especially when using subforms.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question