Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Specifying number of enteries in a subform

Discussion in 'Information Technology' started by JonnyRotten, Jul 28, 2006.

  1. JonnyRotten

    JonnyRotten
    Expand Collapse
    Guest

    I am having a struggle learning about relational table structure, and I
    am coming up with some projects to try to better learn it.
    Well, right now I am stuck on a subform problem.

    Say I have two tables

    Table1
    --------------
    ID (key field, autonumber)
    Name (text)

    Table2
    -------------
    ID (Key Field, number)
    Task

    The ID fields have a relationship built with One-to-many structure.
    I want to make a form and related subform to fill this out. But what I
    want, is when the form loads, it has 5 enteries for the user to fill
    out for table2. No more, no less.
    How can I force the subform to have a certain number of enteries?
     
  2. Loading...

    Similar Threads Forum Date
    Shabad Numbering System New to Sikhism Dec 1, 2015
    USA A Heart Attack And The Numbers Breaking News Aug 2, 2014
    Pacific Borneo: Sikhs small in number, strong in presence Breaking News Nov 11, 2013
    World Shrinking Numbers and Growing Persecution Threaten Sikhs and Hindus in Afghanistan Breaking News Nov 7, 2013
    SciTech Mammals pick offspring’s sex to maximize number of grandchildren, study shows Breaking News Jul 11, 2013

  3. JK

    JK
    Expand Collapse
    Guest

    Hi Jonny

    For clarity lets call the main form "MainForm" and the subform "SubMain" and
    the id's Table1_ID and Table2_ID and assuming the main form is based on
    Table1 and the subform is based on table2:

    In he SUBFORM create a an "OnCurrent" Event Procedure as follows:

    +++++
    Dim numRecs as Long, idnMain as Long

    idnMain=Nz(Forms![MainForm]![Table1_ID] ,0)
    numRecs=Dcount("[Table2_ID]","Table2","[Table2_ID]=" & idnMain)
    Me.Form.AllowAddtions=IIf(numRecs<=5,True,False)
    +++++

    If you actually using the field names as in your example, it is not a good
    idea to give both key fields the same name because it will confuse you (not
    he program) as later you will confuse one "ID" from another, if you did I
    suggest that change them

    Also the word "Name" is a reserved word, suggest that you change it to
    something else (like "Customer Name" or whatever is appropriate) otherwise
    that will cause errors as you progress.

    Regards/JK





    "JonnyRotten" <jgilmour@gmail.com> wrote in message
    news:1153751068.992235.211980@i3g2000cwc.googlegroups.com...
    >I am having a struggle learning about relational table structure, and I
    > am coming up with some projects to try to better learn it.
    > Well, right now I am stuck on a subform problem.
    >
    > Say I have two tables
    >
    > Table1
    > --------------
    > ID (key field, autonumber)
    > Name (text)
    >
    > Table2
    > -------------
    > ID (Key Field, number)
    > Task
    >
    > The ID fields have a relationship built with One-to-many structure.
    > I want to make a form and related subform to fill this out. But what I
    > want, is when the form loads, it has 5 enteries for the user to fill
    > out for table2. No more, no less.
    > How can I force the subform to have a certain number of enteries?
    >
     
  4. JK

    JK
    Expand Collapse
    Guest

    Re: Specifying number of enteries in a subform -oops!!!

    Oops I confused myself

    Table2 must have Table1_ID, There is a one-to-many realation beteen Table1
    and Table2 on Table1_ID

    +++++
    Dim numRecs as Long, idnMain as Long

    idnMain=Nz(Forms![MainForm]![Table1_ID] ,0)
    numRecs=Dcount("[Table2_ID]","Table2","[Table1_ID]=" & idnMain)
    Me.Form.AllowAddtions=IIf(numRecs<=5,True,False)
    +++++
    (2nd line changed)

    Rgds/JK


    "JK" <Nobody@Home.com> wrote in message
    news:e85s%23mzrGHA.984@TK2MSFTNGP05.phx.gbl...
    > Hi Jonny
    >
    > For clarity lets call the main form "MainForm" and the subform "SubMain"
    > and the id's Table1_ID and Table2_ID and assuming the main form is based
    > on Table1 and the subform is based on table2:
    >
    > In he SUBFORM create a an "OnCurrent" Event Procedure as follows:
    >
    > +++++
    > Dim numRecs as Long, idnMain as Long
    >
    > idnMain=Nz(Forms![MainForm]![Table1_ID] ,0)
    > numRecs=Dcount("[Table2_ID]","Table2","[Table2_ID]=" & idnMain)
    > Me.Form.AllowAddtions=IIf(numRecs<=5,True,False)
    > +++++
    >
    > If you actually using the field names as in your example, it is not a good
    > idea to give both key fields the same name because it will confuse you
    > (not he program) as later you will confuse one "ID" from another, if you
    > did I suggest that change them
    >
    > Also the word "Name" is a reserved word, suggest that you change it to
    > something else (like "Customer Name" or whatever is appropriate) otherwise
    > that will cause errors as you progress.
    >
    > Regards/JK
    >
    >
    >
    >
    >
    > "JonnyRotten" <jgilmour@gmail.com> wrote in message
    > news:1153751068.992235.211980@i3g2000cwc.googlegroups.com...
    >>I am having a struggle learning about relational table structure, and I
    >> am coming up with some projects to try to better learn it.
    >> Well, right now I am stuck on a subform problem.
    >>
    >> Say I have two tables
    >>
    >> Table1
    >> --------------
    >> ID (key field, autonumber)
    >> Name (text)
    >>
    >> Table2
    >> -------------
    >> ID (Key Field, number)
    >> Task
    >>
    >> The ID fields have a relationship built with One-to-many structure.
    >> I want to make a form and related subform to fill this out. But what I
    >> want, is when the form loads, it has 5 enteries for the user to fill
    >> out for table2. No more, no less.
    >> How can I force the subform to have a certain number of enteries?
    >>

    >
    >
     

Share This Page