Repost: Forcing User to Enter Data in Subform

J

jody

Sorry to be a pest, but I need to get my form working as
soon as possible. I've been working on it for days and
unfortunately I'm not very proficient at VB. Thanks in
advance.

----------------------------------------------
I have a main form call Company. Within this form I have
a nested subform called ShipInfo. The two forms are
linked using the field: CompanyID. I need the user to
fill in the ShipInfo subform for each company. Even
though I have required fields in the ShipInfo table, the
user can still enter data in the company form and totally
by-pass the ShipInfo subform. What code do I need to
implement so that it forces input in the subform?

Here is how my company and shipinfo tables are set up:

Company Table:
CompanyID (Autonum)
VCID (Text) (Required - This is a vender code ID)
CompName (Text)
**Unique index on VCID

ShipInfo Table:
ShipInfoID (Autonum)
CompanyID (Number) Required
ShipLookupID (Number) Required
**Unique index on CompanyID & ShipLookupID


Would appreciate any suggestions. Thanks much!
 
G

Guest

You can use a Macro in the "before update" of the Main Form
Macr
Conditio
([forms!yourMainFormName!YourSubFormName![FieldinSubForm])Is Null.....Action=msgbox(give a message to inform that the field is not filled in
....(put 3 dots in the next line)...action=cancel event

----- jody wrote: ----

Sorry to be a pest, but I need to get my form working as
soon as possible. I've been working on it for days and
unfortunately I'm not very proficient at VB. Thanks in
advance

---------------------------------------------
I have a main form call Company. Within this form I have
a nested subform called ShipInfo. The two forms are
linked using the field: CompanyID. I need the user to
fill in the ShipInfo subform for each company. Even
though I have required fields in the ShipInfo table, the
user can still enter data in the company form and totally
by-pass the ShipInfo subform. What code do I need to
implement so that it forces input in the subform

Here is how my company and shipinfo tables are set up

Company Table
CompanyID (Autonum)
VCID (Text) (Required - This is a vender code ID
CompName (Text
**Unique index on VCI

ShipInfo Table
ShipInfoID (Autonum
CompanyID (Number) Require
ShipLookupID (Number) Require
**Unique index on CompanyID & ShipLookupI


Would appreciate any suggestions. Thanks much
 
J

Jeff Boyce

Jody

What you're trying to do is difficult. Access MUST save the mainform data
before allowing a move to the subform (which has to have a mainform record
in order to link to). Thus, you can do whatever you want/need to in the
mainform, but cannot confirm that a subform record was touched until the
mainform record is saved -- and that sounds like it might be too late!

Just a guess, but it seems like another approach might be to use a pop-up
form, driven by the AfterUpdate event of the mainform. The pop-up would be
used for the related "many" records you now handle in a subform. You could
require a record in the pop-up before it would close and return control to
the mainform.

NOTE: have you considered what happens if someone starts a mainform, starts
a "subform", and realizes they've made a mistake on the mainform? How will
they be able to step back, if you FORCE them to enter a subform record
(either your way or some other)?

Another approach might be to not force a subform row, and provide an
"exceptions" report that shows all mainform records without accompanying
"many" side rows...
 

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