473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Subform that reverses master/child relationship?

I have two tables: Persons and Households, in a many-to-one relationship (many persons in one household). Persons has householdID as FK. The problem is that I
want my form to use Persons as the master. That is b/c the user interface is entirely person-oriented -- searching, creating new records, etc. is done person
by person, not household by household.

But when I try to set up the form with this reversed relationship, I get a "You tried to assign a Null value to a variable that is not a Variant data type"
error (upon entering data in the subform). I tried reversing the link fields, but access didn't seem to like that. Any thoughts would be much appreciated!
Nov 12 '05 #1
6 1842
Unless I'm missing something, you have no need to use a subform. If you base
your form on the Persons table and include a combo that is bound to
Persons.HouseholdID (and then use your Households table as the .RowSource of
the combo), that would allow you to add choose the household to which each
person belongs.
--
Scott McDaniel
CS Computer Software
www.thedatabaseplace.net

"Phil M" <sz************@yahoo.com> wrote in message
news:11*************@news.rcn.com...
I have two tables: Persons and Households, in a many-to-one relationship (many persons in one household). Persons has householdID as FK. The problem
is that I want my form to use Persons as the master. That is b/c the user interface is entirely person-oriented -- searching, creating new records, etc. is done
person by person, not household by household.

But when I try to set up the form with this reversed relationship, I get a "You tried to assign a Null value to a variable that is not a Variant data
type" error (upon entering data in the subform). I tried reversing the link fields, but access didn't seem to like that. Any thoughts would be much
appreciated!

Nov 12 '05 #2

Yes, that works if the household already exists, but I'd like to be able to create a new household on the same form, if possible. In other words, the user
doesn't need to know that "household" is normalized in the table model.

On Mon, 5 Jan 2004 17:58:54 -0500, "Scott McDaniel" <scott@NOSPAM__thedatabaseplace.net> wrote:
Unless I'm missing something, you have no need to use a subform. If you base
your form on the Persons table and include a combo that is bound to
Persons.HouseholdID (and then use your Households table as the .RowSource of
the combo), that would allow you to add choose the household to which each
person belongs.
--
Scott McDaniel
CS Computer Software
www.thedatabaseplace.net

"Phil M" <sz************@yahoo.com> wrote in message
news:11*************@news.rcn.com...
I have two tables: Persons and Households, in a many-to-one relationship

(many persons in one household). Persons has householdID as FK. The problem
is that I
want my form to use Persons as the master. That is b/c the user interface

is entirely person-oriented -- searching, creating new records, etc. is done
person
by person, not household by household.

But when I try to set up the form with this reversed relationship, I get a

"You tried to assign a Null value to a variable that is not a Variant data
type"
error (upon entering data in the subform). I tried reversing the link

fields, but access didn't seem to like that. Any thoughts would be much
appreciated!



Nov 12 '05 #3
Two things come to mind:
1. I built a 5-level hierarchy (company, region, division, location,
person), and encountered the same problem as you, only more so.
Solution there was to force the user to start at the top (not
particularly elegant, as you have mentioned.)

2. Combo boxes (i.e., the one used to select the correct Household)
have a NotInList event that can be used to open a new form. If the
user tries to assign the person to a non-existant household, then your
program could append the new household to the appropriate table, open
the appropriate household form (modally??) and requery the combo box
when the user finishes entering the household information. If the
household does not require any information besides its name, then you
would not need to open the form.

I would be curious to learn whether there is a more elegant solution.
On Tue, 06 Jan 2004 00:37:26 GMT, Phil M <sz************@yahoo.com>
wrote:

Yes, that works if the household already exists, but I'd like to be able to create a new household on the same form, if possible. In other words, the user
doesn't need to know that "household" is normalized in the table model.

On Mon, 5 Jan 2004 17:58:54 -0500, "Scott McDaniel" <scott@NOSPAM__thedatabaseplace.net> wrote:
Unless I'm missing something, you have no need to use a subform. If you base
your form on the Persons table and include a combo that is bound to
Persons.HouseholdID (and then use your Households table as the .RowSource of
the combo), that would allow you to add choose the household to which each
person belongs.
--
Scott McDaniel
CS Computer Software
www.thedatabaseplace.net

"Phil M" <sz************@yahoo.com> wrote in message
news:11*************@news.rcn.com...
> I have two tables: Persons and Households, in a many-to-one relationship

(many persons in one household). Persons has householdID as FK. The problem
is that I
> want my form to use Persons as the master. That is b/c the user interface

is entirely person-oriented -- searching, creating new records, etc. is done
person
> by person, not household by household.
>
> But when I try to set up the form with this reversed relationship, I get a

"You tried to assign a Null value to a variable that is not a Variant data
type"
> error (upon entering data in the subform). I tried reversing the link

fields, but access didn't seem to like that. Any thoughts would be much
appreciated!
>
>




Nov 12 '05 #4
NB
> 2. Combo boxes (i.e., the one used to select the correct Household)
have a NotInList event that can be used to open a new form. If the
user tries to assign the person to a non-existant household, then your
program could append the new household to the appropriate table, open
the appropriate household form (modally??) and requery the combo box
when the user finishes entering the household information. If the
household does not require any information besides its name, then you
would not need to open the form.


This is the right approach. In one of my apps, there is a similar
scenario: a patient may have several admittance to hospital, but most
operations are per admittance. So the form are based on admittance
table, and user just pulls the patient from the patient table to
assign to that admittance. If the patient is new then a pop up form
will allow user to add new patient.

NB
Nov 12 '05 #5

I would be curious to learn whether there is a more elegant solution.

Well, from a UI standpoint, it would be nicer to keep all the fields on one page -- I think I could do this if I were willing to undefine the FK
relationship and manage it manually in VB code. But I'm not sure it's worth the effort. Also considered denormalizing households and putting all the fields
into Persons... Then the UI becomes really simple.

Thanks to everyone who responded for their thoughts!

On Tue, 06 Jan 2004 00:37:26 GMT, Phil M <sz************@yahoo.com>
wrote:

Yes, that works if the household already exists, but I'd like to be able to create a new household on the same form, if possible. In other words, the userdoesn't need to know that "household" is normalized in the table model.

On Mon, 5 Jan 2004 17:58:54 -0500, "Scott McDaniel" <scott@NOSPAM__thedatabaseplace.net> wrote:
Unless I'm missing something, you have no need to use a subform. If you base
your form on the Persons table and include a combo that is bound to
Persons.HouseholdID (and then use your Households table as the .RowSource of
the combo), that would allow you to add choose the household to which each
person belongs.
--
Scott McDaniel
CS Computer Software
www.thedatabaseplace.net

"Phil M" <sz************@yahoo.com> wrote in message
news:11*************@news.rcn.com...
> I have two tables: Persons and Households, in a many-to-one relationship
(many persons in one household). Persons has householdID as FK. The problem
is that I
> want my form to use Persons as the master. That is b/c the user interface
is entirely person-oriented -- searching, creating new records, etc. is done
person
> by person, not household by household.
>
> But when I try to set up the form with this reversed relationship, I get a
"You tried to assign a Null value to a variable that is not a Variant data
type"
> error (upon entering data in the subform). I tried reversing the link
fields, but access didn't seem to like that. Any thoughts would be much
appreciated!
>
>



Nov 12 '05 #6
Hi, Phil;

My solution has been to use the combo box to choose household, and if it isn't
on the list, give them a button (or you could use the notInList property) to
pop up a dialog to create the household (then don't forget to refresh the combo
after you close the dialog!). It works and it's pretty intuitive to the user.
I wouldn't go the denormalized route--will come back to bite you later.

Good luck.

Jan
I have two tables: Persons and Households, in a many-to-one relationship
(many persons in one household). Persons has householdID as FK. The problem
is that I
want my form to use Persons as the master. That is b/c the user interface is
entirely person-oriented -- searching, creating new records, etc. is done
person
by person, not household by household.

But when I try to set up the form with this reversed relationship, I get a
"You tried to assign a Null value to a variable that is not a Variant data
type"
error (upon entering data in the subform). I tried reversing the link fields,
but access didn't seem to like that. Any thoughts would be much appreciated!

Jan Stempel
Stempel Consulting
Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ray | last post by:
I have a main form with a subform. The main form has a combo box which lists all the clients which in turn are displayed in the subform. The subform is bound to the combo box and all work well....
0
by: Alienz | last post by:
Hey all. if anyone is REALLY bored please help moi. I am new to access stuff and am probably missing something obvious here. I have 2 tables that are linked via "number" in the relationship...
4
by: Sabra D via AccessMonster.com | last post by:
I have a db with 3 tables, owner, lessee, and tract, tract is the main table and has two lookup fields to find the owner and lessee info. My problem - i have a form with the owner info on top and...
1
by: kkrizl | last post by:
I have a form that displays general information about an alarm permit location. There's a subform that shows detailed information about burglar alarms that have gone off at the location. When a...
6
by: tlyczko | last post by:
I am working on an audits database. The main table, Audits, has an AuditID primary key. Another table, 1:1 relationship, ProgramAudits, has AuditID as a foreign key. I have a master/main form...
2
by: John | last post by:
I have two tables in a 1:M relationship- the parent has 5 fields in the primary key and the child 6 (these are actually pretty far downstream in a complicated ER model, but the problem is between...
4
by: Ecohouse | last post by:
have a main form with two tabs, and each tab has a subform. The first tab's subform refers to the mainform (this works). The second tab's subform refers to the identity key of the first tab's...
8
Megalog
by: Megalog | last post by:
Hey guys.. my turn to ask a question: I'm having a weird issue with a form I've reworked. This form has a combo box, which when used is changing the recordsource of a subform. This subform has...
3
by: jonceramic | last post by:
Hi, I have a 2 subform form, which uses the selection of a row in subform 1 to show a set of rows in subform 2. I have my queries pointing directly to fields on my form to choose what data is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.