What is the easist way to make a form be blank when first opened?

  • Thread starter Thread starter Rachel Garrett
  • Start date Start date
R

Rachel Garrett

I have a working combo box that allows the user to select a value, and
the rest of the form populates with data from query results. A few
fields are editable, and I disabled the rest. This is working, but I'm
wondering what the easiest way is to make the form be blank when the
user first opens it. Right now, it displays all the data for the first
record in the query results, and then the data changes after the user
selects a value. This would confuse some of the users.

Thanks,
Rachel
 
Rachel,

Initially you can force the form to load with no records, by saving the
RecordSource as:
SELECT * FROM tblClient WHERE (False);

This avoids the #Name error

Replace tblClient with the name of your table
You can use the query above as the recordsource of your form until you set
the recordsource again after the user selects something in the combo.


Jeanette Cunningham -- Melbourne Victoria Australia
 
Rachel Garrett said:
I have a working combo box that allows the user to select a value, and
the rest of the form populates with data from query results. A few
fields are editable, and I disabled the rest. This is working, but I'm
wondering what the easiest way is to make the form be blank when the
user first opens it. Right now, it displays all the data for the first
record in the query results, and then the data changes after the user
selects a value. This would confuse some of the users.

If the form is intended for entry of new data, you can, in the data tab of
its properties sheet, set the Data Entry property to Yes.

Alternatively, you could use GoToNewRecord to move to a new Record when that
Form opens.

Larry Linson
Microsoft Office Access MVP
 
Thanks Marsh

Jeanette Cunningham -- Melbourne Victoria Australia

Marshall Barton said:
Jeanette,

That will work, but for a large table might be slow. It
would be better to allow Access to utilize its indexing
optimazations by using a WHERE clause with the primary key
compared to an impossible value. E.g. WHERE ID = 0
This way no records have to be retrieved whereas WHERE False
must load all the records to filter them out.

Depending on what Rachel wants to do, it might be easier to
use the OpenForm method's DateMode argument set to
acFormAdd. Alternatively, using the WhereCondition argument
set to "ID = 0" (or even "False") would load no records
withour having to mess with the record source query.
--
Marsh
MVP [MS Access]


Jeanette said:
Initially you can force the form to load with no records, by saving the
RecordSource as:
SELECT * FROM tblClient WHERE (False);

This avoids the #Name error

Replace tblClient with the name of your table
You can use the query above as the recordsource of your form until you set
the recordsource again after the user selects something in the combo.


Jeanette Cunningham -- Melbourne Victoria Australia
 
Jeanette,

That will work, but for a large table might be slow.  It
would be better to allow Access to utilize its indexing
optimazations by using a WHERE clause with the primary key
compared to an impossible value.  E.g.  WHERE ID = 0
This way no records have to be retrieved whereas WHERE False
must load all the records to filter them out.

Depending on what Rachel wants to do, it might be easier to
use the OpenForm method's DateMode argument set to
acFormAdd.  Alternatively, using the WhereCondition argument
set to "ID = 0" (or even "False") would load no records
withour having to mess with the record source query.

Thanks to everyone for the responses. Users will not be creating any
new records. They will be selecting the name (index) of the record
they want to change a few fields in. Right now, it starts off showing
them the record for 1.1 before they've picked 3.2, 4.6, etc. in the
combo box.

I don't understand where I would put the WHERE clause for ID = 0. If I
put it in the query itself that the form looks at, the query will
return no data and the form will always be blank. Is this something I
would be doing in VBA or SQL?

Thanks,
Rachel
 
Back
Top