Open a read-only form to a blank record

  • Thread starter klp via AccessMonster.com
  • Start date
K

klp via AccessMonster.com

I have a form that is parent/child. It is a read-only form, but I want to be
able to open the form to a blank record. So that the user can then go in and
either search for the customer they are looking for or enter in their number.
Is there a way to do this?

Thanks in advance -

Kim P
 
K

Klatuu

The only way to open a form with no data is to go to a new record in the
form's load event; however, since it is read only, you can't do that.
However, one workaround would be to create a "dummy" record with no data and
go to that record in the form load event. The only issue with that is where
ever you use the table, you will have to use a query that filters the dummy
out.

Another way would be to use a Union Query and create the dummy record in the
query. Here is an example:

SELECT MDB_CLIENT, MDB_REGION, MDB_REGION_NBR, MDB_NAME,
MDB_PWD,MDB_CHECK_OUT_TIME, MDB_CHECKED_OUT_BY, MDB_INCLUDE, MDB_LAST_COMPACT
FROM tblMdbList UNION SELECT Null As MDB_CLIENT, Null As MDB_REGION, Null
As MDB_REGION_NBR, Null As MDB_NAME, Null As MDB_PWD, Null As
MDB_CHECK_OUT_TIME, Null As MDB_CHECKED_OUT_BY, Null As MDB_INCLUDE, Null
As MDB_LAST_COMPACT FROM tblMdblist;

The only problem with either of these solutions is that if you have a Yes/No
field in your table, Nulls are translated to 0 and that will show in the
control as False.
 
K

klp via AccessMonster.com

Wonderful, thank you! That worked just as I needed.
The only way to open a form with no data is to go to a new record in the
form's load event; however, since it is read only, you can't do that.
However, one workaround would be to create a "dummy" record with no data and
go to that record in the form load event. The only issue with that is where
ever you use the table, you will have to use a query that filters the dummy
out.

Another way would be to use a Union Query and create the dummy record in the
query. Here is an example:

SELECT MDB_CLIENT, MDB_REGION, MDB_REGION_NBR, MDB_NAME,
MDB_PWD,MDB_CHECK_OUT_TIME, MDB_CHECKED_OUT_BY, MDB_INCLUDE, MDB_LAST_COMPACT
FROM tblMdbList UNION SELECT Null As MDB_CLIENT, Null As MDB_REGION, Null
As MDB_REGION_NBR, Null As MDB_NAME, Null As MDB_PWD, Null As
MDB_CHECK_OUT_TIME, Null As MDB_CHECKED_OUT_BY, Null As MDB_INCLUDE, Null
As MDB_LAST_COMPACT FROM tblMdblist;

The only problem with either of these solutions is that if you have a Yes/No
field in your table, Nulls are translated to 0 and that will show in the
control as False.
I have a form that is parent/child. It is a read-only form, but I want to be
able to open the form to a blank record. So that the user can then go in and
[quoted text clipped - 4 lines]
 
K

Klatuu

Good. Just curious about which method you used.
Also, to help others who may have a similar question, please rate the
response so it will be saved and others searching for a solution will be able
to find the answer.
--
Dave Hargis, Microsoft Access MVP


klp via AccessMonster.com said:
Wonderful, thank you! That worked just as I needed.
The only way to open a form with no data is to go to a new record in the
form's load event; however, since it is read only, you can't do that.
However, one workaround would be to create a "dummy" record with no data and
go to that record in the form load event. The only issue with that is where
ever you use the table, you will have to use a query that filters the dummy
out.

Another way would be to use a Union Query and create the dummy record in the
query. Here is an example:

SELECT MDB_CLIENT, MDB_REGION, MDB_REGION_NBR, MDB_NAME,
MDB_PWD,MDB_CHECK_OUT_TIME, MDB_CHECKED_OUT_BY, MDB_INCLUDE, MDB_LAST_COMPACT
FROM tblMdbList UNION SELECT Null As MDB_CLIENT, Null As MDB_REGION, Null
As MDB_REGION_NBR, Null As MDB_NAME, Null As MDB_PWD, Null As
MDB_CHECK_OUT_TIME, Null As MDB_CHECKED_OUT_BY, Null As MDB_INCLUDE, Null
As MDB_LAST_COMPACT FROM tblMdblist;

The only problem with either of these solutions is that if you have a Yes/No
field in your table, Nulls are translated to 0 and that will show in the
control as False.
I have a form that is parent/child. It is a read-only form, but I want to be
able to open the form to a blank record. So that the user can then go in and
[quoted text clipped - 4 lines]
 
K

klp via AccessMonster.com

I used the union query. To avoid keeping a blank record in the table.

Thanks again!

ps. I will go ahead and rate the response.
Good. Just curious about which method you used.
Also, to help others who may have a similar question, please rate the
response so it will be saved and others searching for a solution will be able
to find the answer.
Wonderful, thank you! That worked just as I needed.
[quoted text clipped - 24 lines]
 
M

martinjb47

Hey guys,

I was using the union method too but you have to go in and amend the source if you change the table which annoys the hell out of me, just seems a bit messy.

I find this method a bit less convoluted;
Private Sub Form_Load()
DoCmd.GoToRecord , Me.Name, acNewRec
End Sub

Set 'Allow Additions' to 'Yes' in form properties.

My form is also read-only so I set locked to 'Yes' for all the controls linked to my table as 'Allow Edits'='No' prevents any control on the form being changed and I have a search box.

Cheers, Martin
 
A

Allen Browne

See:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html

The code loops through the controls on the form, and sets the Locked
property of the bound controls, leaving the unbound ones (like your search
box) operational.
 

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