Open Form Artificially Blank

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
 
J

John W. Vinson

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.
 
A

AccessVandal via AccessMonster.com

Well, for me I would use the form's properties.

1. Allow Edits
2. Allow Deletions
3. Allow Additions
4. Data Entry

You can use the OnOpen event or in the form's properties to set 1 or 2 or 3
to "No" and set Data Entry to Yes. Setting DataEntry to "Yes" will show blank
record on the form and AllowEdits to "No" will prevent data entry. Setting
certain combination may hide your controls but you can use the search combo
box in the form's header to change the form's properties "Allow
Edits/Additons" and "Data Entry". (do not place the search combo in the
detail section of the form)
 
J

jschping

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
 
J

John W. Vinson

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.
 
C

Chegu Tom

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
 

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