Display fields based on number (1 Viewer)

SDB

Registered User.
Local time
Today, 22:29
Joined
Sep 16, 2004
Messages
39
Hi Guys and Girls,

While doing a rabbit DB for the missus I have hit a problem, if one of the does gives birth to 3 babies i wish to have the details entered onto a form (not a problem) but i would like to do this:

if number of babies = 3 then fields to display to enter details is 3 on the form, i have my table setup with up to 10 seperate field for the babies per record but am stuck trying to do this

any help or direction would be great
 

MarkK

bit cruncher
Local time
Today, 14:29
Joined
Mar 17, 2004
Messages
8,187
You need one Bunnies table and you need one record for each bunny, so that any bunny can have any number of other bunnies as children. Then each of your new bunnies can have new bunnies of their own. This will happen.
I'd make a table with fields like this
bunnyID - Primary Key
mommyID - Foreign Key
bunnyName
bunnySex
bunnyDescription

Then I'd make a NewBunnies form showing mommy, and a continuous sub-form of babies into which you might add any number of babies, each being granted its own new record in the table.
 

SDB

Registered User.
Local time
Today, 22:29
Joined
Sep 16, 2004
Messages
39
sorry lagbolt, thats what i already do, I should of made my request more descriptive, I have a breding table that has mother father date due etc and an amount field for when they are are born (any thing from 1 - 9) its this part i am having problems with, I have another form that has the mother father date born etc fields on and i have the amoutns field as well eg 3, what i am after is the form to only dispaly 3 fields to enter in color sex etc not the 9 i have created, eg if the next doe has 7 then display 7 fileds to enter color sex etc, hope this makes it clearer. what i am after is continus form that only show the fields as per babies born???

thanks to al that have looked
 

Attachments

  • Knowledge base.zip
    11.1 KB · Views: 85
Last edited:

MarkK

bit cruncher
Local time
Today, 14:29
Joined
Mar 17, 2004
Messages
8,187
I'm not sure where you're stumped, and maybe you've got this stuff already, but here's where I'd start with a continuous form for babies. The "Does" form offers a sub-form "babyList" that is a continuous form, and you can add babies in there and you don't need to know how many there will be.
I think it's cool you're making a bunny db for the missus.
Hope this helps.

And how do you figure out who the daddy is?
 

Attachments

  • bunnies.zip
    12 KB · Views: 103

SDB

Registered User.
Local time
Today, 22:29
Joined
Sep 16, 2004
Messages
39
Hi Lagbolt, your Db is what i have done at the moment but what i would like to do as per attached image, the 'amount of babies' field on the breeding details form controls how many fileds are displayed on the babies details form, were i have entered five babies born, i wish to only see 5 fields on the babies details, not the nine i have there (and i should of taken the details out before taking picture doh) its a cross between your method and trying to make it child friendly for other users in the rabbit club. where as most access user understandhow to enter the records I want to only let the end user see the amount of fields on babies details as per amount born...as for the father you only bred to the one buck and wait 31 days for the results or thats the idea :)
 

SDB

Registered User.
Local time
Today, 22:29
Joined
Sep 16, 2004
Messages
39
helps if i attach the image...
 

Attachments

  • Image2.jpg
    Image2.jpg
    33.9 KB · Views: 112

MarkK

bit cruncher
Local time
Today, 14:29
Joined
Mar 17, 2004
Messages
8,187
Do you mean 5 fields or 5 records? I'm assuming you mean records, and if you mean records you shouldn't have to count them first and then write code to display them, but rather, you need to create a record source for the babies details form that goes something like...
"SELECT Colour, Sex, Notes FROM Bunnies WHERE PappaID = " & <Dave's ID> & " AND mammaID = " & <Trinity's ID> & " AND BirthDate >= #" & <specify some date range here> & "#;"
This will limit the number of records appearing in the "babies details" form to only those that satisfy the specified criteria, and the babies details form can then show all their babies, ever, or for certain dates.

What logic do you use to determine that this form should show five offspring?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 17:29
Joined
Feb 19, 2002
Messages
43,484
I changed the table and added relationships. I also built a very simplistic main/subform to let you enter information regarding offspring.

You are thinking in terms of spreadsheets and unnormalized tables. In a relational database, once you have more than one of something, you have many. In the subform, you would just enter as many rows as there are babies. You don't need to enter a number beforehand. Your design also will have problems with subsequent litters unless you intend it to be only for data entry.
 

Attachments

  • bunniesPat.zip
    17.7 KB · Views: 94

SDB

Registered User.
Local time
Today, 22:29
Joined
Sep 16, 2004
Messages
39
the offspring should follow the amount born field, you code is what i am looking for i tried x amount of samples and couldn,t get it to work,i will try yours and see what happens..should be fine i have been looking at the trees but can't see them cos of the forest....thanks for the help..
 

Users who are viewing this thread

Top Bottom