How to clear bound controls on form load?

A

abrown

I'm sure the code is very simple, but I'm having trouble figuring it out. I
have a main form (which is bound to a table) that opens when selected from
the main switchboard. I want this form to open with all fields cleared;
however, since all of the fields are bound to the table the form opens with
the record I last viewed. How can I get the form to open with all controls
cleared even though they are bound to a table?

Thanks,
Amber
 
F

fredg

I'm sure the code is very simple, but I'm having trouble figuring it out. I
have a main form (which is bound to a table) that opens when selected from
the main switchboard. I want this form to open with all fields cleared;
however, since all of the fields are bound to the table the form opens with
the record I last viewed. How can I get the form to open with all controls
cleared even though they are bound to a table?

Thanks,
Amber

Clearing the bound controls when a form opens will delete the data in
the first record in the table.
I don't think that is what you wish to do.
So... instead of asking How, why not tell us What (you wish to
accomplish).
 
A

abrown

No, I don't want to delete any of the information in the table.

What I want to accomplish is...when the user exits the main form to go back
to the switchboard, then opens the main form again...I want all of the
controls to be null on form load. From there the user will decide whether to
search for a record or enter a new record. I don't want the last record
viewed to still be visible on form load.

Thanks,
Amber
 
S

strive4peace

Hi Amber,

it sounds like you want the form to go a new record when it is opened

put this code in the [Event Procedure] for the form LOAD event:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub Form_Load()
If Not Me.NewRecord Then
DoCmd.RunCommand acCmdRecordsGoToNew
End If
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If the user doesn't type anything, the new record will not be saved

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 
F

fredg

No, I don't want to delete any of the information in the table.

What I want to accomplish is...when the user exits the main form to go back
to the switchboard, then opens the main form again...I want all of the
controls to be null on form load. From there the user will decide whether to
search for a record or enter a new record. I don't want the last record
viewed to still be visible on form load.

Thanks,
Amber

Then you probably want to open the form to a new record.
Code the Form's Load event:
DoCmd.RunCommand acCmdRecordsGoToNew

The existing records will be available simply by using the navigation
buttons.
 
A

abrown

That worked! Thanks!

strive4peace said:
Hi Amber,

it sounds like you want the form to go a new record when it is opened

put this code in the [Event Procedure] for the form LOAD event:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub Form_Load()
If Not Me.NewRecord Then
DoCmd.RunCommand acCmdRecordsGoToNew
End If
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If the user doesn't type anything, the new record will not be saved

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*



No, I don't want to delete any of the information in the table.

What I want to accomplish is...when the user exits the main form to go back
to the switchboard, then opens the main form again...I want all of the
controls to be null on form load. From there the user will decide whether to
search for a record or enter a new record. I don't want the last record
viewed to still be visible on form load.

Thanks,
Amber
 
S

strive4peace

you're welcome, Amber ;) happy to help

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*



That worked! Thanks!

strive4peace said:
Hi Amber,

it sounds like you want the form to go a new record when it is opened

put this code in the [Event Procedure] for the form LOAD event:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub Form_Load()
If Not Me.NewRecord Then
DoCmd.RunCommand acCmdRecordsGoToNew
End If
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If the user doesn't type anything, the new record will not be saved

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*



No, I don't want to delete any of the information in the table.

What I want to accomplish is...when the user exits the main form to go back
to the switchboard, then opens the main form again...I want all of the
controls to be null on form load. From there the user will decide whether to
search for a record or enter a new record. I don't want the last record
viewed to still be visible on form load.

Thanks,
Amber

:

On Tue, 15 Jul 2008 12:34:00 -0700, abrown wrote:

I'm sure the code is very simple, but I'm having trouble figuring it out. I
have a main form (which is bound to a table) that opens when selected from
the main switchboard. I want this form to open with all fields cleared;
however, since all of the fields are bound to the table the form opens with
the record I last viewed. How can I get the form to open with all controls
cleared even though they are bound to a table?

Thanks,
Amber
Clearing the bound controls when a form opens will delete the data in
the first record in the table.
I don't think that is what you wish to do.
So... instead of asking How, why not tell us What (you wish to
accomplish).
 

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