Open Form Artificially Blank

  • Thread starter Thread starter jschping
  • Start date Start date
J

jschping

Hi,

I have a form bound to a set number of records. I do not want the user to be
able to add any new records.

I have a combo box with some VB code to allow the user to select one of the
records to be able to edit it.

When they first open the form, it shows the first record's info. I would
prefer that all the fields were blank until they use the combo-box to select
a record.

How can I do this? I don't want to create a dummy blank record and make that
open first, because then I have an empty record floating around to mess up my
reports. Also, I don't want the user to be able to edit that "dummy" record
and give it info.

What do you suggest?

Thanks!!!

John Schping
 
Hi,

I have a form bound to a set number of records. I do not want the user to be
able to add any new records.

I have a combo box with some VB code to allow the user to select one of the
records to be able to edit it.

When they first open the form, it shows the first record's info. I would
prefer that all the fields were blank until they use the combo-box to select
a record.

How can I do this? I don't want to create a dummy blank record and make that
open first, because then I have an empty record floating around to mess up my
reports. Also, I don't want the user to be able to edit that "dummy" record
and give it info.

What do you suggest?

Thanks!!!

John Schping

About the only way would be to base the form on a Query which you can be sure
returns no records. Say you have an Autonumber primary key (that the combo box
uses to select the record); you could base the form on a query selecting

IDField = 0

as a criterion (after assuring yourself that there is no 0 record!!)

The code in the combo box would then change the form's recordsource to the
single record containing that value.

This has the additional advantage that the form is never populated by more
than one record, making it more efficient - especially if you have a split
application or a SQL/Server network backend.
 
Hi,

Thanks for replying.

Your idea sounds great, especially since it will be a split database over a
network.

What code do I use to change the SQL behind a forms recordset?

Thanks,

John Schping
 
What code do I use to change the SQL behind a forms recordset?

Me.RecordSource = strSQL

where strSQL is a valid SQL statement returning the fields that you want on
the form.
 
You may want to use a main form and subform
The main form is unbound and has the combo box to select a record. Default
value is null
The subform (your current form minus the combo box) is bound to your table
and linked to the main form by the combo box.

When you start the subform will be empty. When you select a record in the
combo box of the main form the subform is populated
 
Back
Top