check empty subform

S

spring

I have two subforms:

one for main and one for detail.

If the main subform is filled, it should not be able to jump to other
records until the detail subform is also filled.

I have tried to check it in BeforeUpdate in main subform, but it even
prevents me jumping to the detail subform.
I also tried in Current, but it cannot Cancel the navigating operation.

Any hints will be appreciated.
 
J

Jeanette Cunningham

Hi spring,
one way to force this is to open the main form to a single record.
If the main form can't go to a different record or another new record, the
only options left for the user are to close the main form or fill in the
detail subform.

I am assuming that your description of --> I have two subforms:
one for main and one for detail. --> means one main form with one subform.

To open the main form to add only one new record, make allow additions set
to no and data entry set to no for the main form.
Open the form with this code:
DoCmd.OpenForm "NameOfForm", DataMode:=acAdd

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
J

Jeanette Cunningham

Oops - that should be
acFormAdd

Replace
DoCmd.OpenForm "NameOfForm", DataMode:=acAdd

with

DoCmd.OpenForm "NameOfForm", DataMode:=acFormAdd

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
S

spring

Thanks Jeanette.

actually i have those two subforms on a bigger form.
the two subforms are linked.

Also I need to change previous records.
 
J

Jeanette Cunningham

Assuming that the main form is bound to a table on the 'one' side of a one
to many relationship and the subform is bound to the 'many' side of the same
relationship, that makes it much more difficult. I don't really know what to
suggest. The main form can have many subform records for the same record of
the main form.
Access is not intended to be used the way you are suggesting - access is
deliberately set up so that you can enter many child records for the same
record in the parent form. Hopefully someone else can jump in here with an
idea.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
S

spring

that's exactly the case.

maybe I should restart from designing the forms.
maybe I can just drop this idea.

Jeanette, thanks very much for your help!
 

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