How can I keep my the text and combo boxes blank every time I open my form (1 Viewer)

Mezta1988

Registered User.
Local time
Today, 05:54
Joined
Jan 22, 2019
Messages
41
Hi,

I noticed in MS ACCESS that, if you associate any bound or unbound text boxes fields and combo boxes fields to your table then those fields will automatically show up the record from the table from which those fields are associated with.

Now, what if I want to keep those field blank every time I open up the form, what I mean is keep them blank until I manually populate them. I tried to search for a tutorials for two days now and I find nothing.
 

mike60smart

Registered User.
Local time
Today, 03:54
Joined
Aug 6, 2017
Messages
1,917
Hi

In the design View of the Form

You need to create an On Open Event

Then you would use this:-

Me.ComboboxName = Null

Do this for all of your Combobox's
 

Mezta1988

Registered User.
Local time
Today, 05:54
Joined
Jan 22, 2019
Messages
41
I already tried that but it only clears the text box and the other fields. But when you type entries directly to the field without clicking a button to start for a new record then it will just edit whatever the first stored record in your table.

Is it may be possible to attach a code on the On load event that will tell the form to start a new record once the is open up?
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 03:54
Joined
Jan 14, 2017
Messages
18,259
Sorry but that makes no sense at all.
If you use an unbound combo (or textbox), it will always be blank until you select something.

However bound combos (like bound textboxes) will by design show previously saved data for each record
BUT if you move to a NEW record these will be blank.

If you want to open your form to a new record, then set it for data entry
DoCmd.OpenForm "YourFormName", , , ,acFormAdd
 

Mezta1988

Registered User.
Local time
Today, 05:54
Joined
Jan 22, 2019
Messages
41
Where can I find that Data Entry property?
I use
Code:
DoCmd.GoToRecord , , acNewRec
an it work, but I want to know also how
Code:
DoCmd.OpenForm "YourFormName", , , ,acFormAdd
works.
 

isladogs

MVP / VIP
Local time
Today, 03:54
Joined
Jan 14, 2017
Messages
18,259
You can set the Data Entry property to Yes on the Data tab of the form Property sheet. If you do so, the form will only open to a single blank record and so it can't be used for viewing/editing existing records.

However the same form can be used for both adding records and editing existing records by using different arguments

As previously stated, DoCmd.OpenForm "YourFormName", , , ,acFormAdd opens a form to a new record.

DoCmd.OpenForm "YourFormName", , , ,acFormEdit opens to existing records but of course you can also add new records if you wish.

The acFormEdit argument is the default and can be omitted. In other words this does exactly the same thing: DoCmd.OpenForm "YourFormName"
 

Mezta1988

Registered User.
Local time
Today, 05:54
Joined
Jan 22, 2019
Messages
41
Thank you @isladog it works like a hot knife through butter.
 

Users who are viewing this thread

Top Bottom