Form / Subform Problems loading Data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nic

    Form / Subform Problems loading Data

    Hi

    I am currently having problems getting two forms to behave the way I
    want. I have two tables Student and Application, and their respective
    forms. (Tables)Student has StudentID (PK) & an ApplicationID. And
    Application has ApplicationID as its primary key.

    With the main Form being the Student_Details form, I have a Button
    which loads the Application Form. The way I want it to behave is when
    the Load_AppForm button is clicked the following occurs; if an
    applicationID exists in the student table then it loads the relevant
    Application Details in the Application_Det ails form. Otherwise if the
    Student table has no ApplicationID (ie, currently null, a new student)
    then the Application Form will load to a new record, and then when all
    data has been inputted here the ApplicationID is passed back to the
    Student_Details form, and hence saved in the Student Table.

    The following VB code within the Load_AppForm_Bu tton_Click routine
    doesn't quite work...and know that I will also need code behind the
    Application Form as well.

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Application_De tails"

    If Not IsNull([Forms]![Student_Details]![S_ApplicationID _txt])
    Then
    stLinkCriteria =
    "[Forms]![Student_Details]![S_ApplicationID _txt]=" &
    Me![ApplicationID_t xt]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Else
    DoCmd.OpenForm "Application_De tails"
    End If

    Any advise would be greatly appreciated.

    Thanks nic
  • MazeMan

    #2
    Re: Form / Subform Problems loading Data

    Nic,

    I don't want to be rude, but if there is a 1:1 relation between a student
    and an application, why don't you create a single table which contains all
    data? If you don't have to split a table don't.
    Another solution might be to keep the student form and to drag a
    subform-control into it which has to refer to the application form. This
    will handle the relational issues automatically. One major drawback is that
    you have make some adjustments in both tables. You have to drop the
    ApplicationID attribute in the student-table and add the StudentID attribute
    to the application-table. Before you go any further, I think it is a good
    idea to take a closer look at the subform-control documentation. This
    control offers a lot of advantages in cases like this but it will take some
    time to understand what it is doing.

    Good luck!

    "nic" <nicfantis@yaho o.co.uk> schreef in bericht
    news:aa26ac1d.0 401290822.269d8 0b6@posting.goo gle.com...[color=blue]
    > Hi
    >
    > I am currently having problems getting two forms to behave the way I
    > want. I have two tables Student and Application, and their respective
    > forms. (Tables)Student has StudentID (PK) & an ApplicationID. And
    > Application has ApplicationID as its primary key.
    >
    > With the main Form being the Student_Details form, I have a Button
    > which loads the Application Form. The way I want it to behave is when
    > the Load_AppForm button is clicked the following occurs; if an
    > applicationID exists in the student table then it loads the relevant
    > Application Details in the Application_Det ails form. Otherwise if the
    > Student table has no ApplicationID (ie, currently null, a new student)
    > then the Application Form will load to a new record, and then when all
    > data has been inputted here the ApplicationID is passed back to the
    > Student_Details form, and hence saved in the Student Table.
    >
    > The following VB code within the Load_AppForm_Bu tton_Click routine
    > doesn't quite work...and know that I will also need code behind the
    > Application Form as well.
    >
    > Dim stDocName As String
    > Dim stLinkCriteria As String
    >
    > stDocName = "Application_De tails"
    >
    > If Not IsNull([Forms]![Student_Details]![S_ApplicationID _txt])
    > Then
    > stLinkCriteria =
    > "[Forms]![Student_Details]![S_ApplicationID _txt]=" &
    > Me![ApplicationID_t xt]
    > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > Else
    > DoCmd.OpenForm "Application_De tails"
    > End If
    >
    > Any advise would be greatly appreciated.
    >
    > Thanks nic[/color]


    Comment

    • Nicholas Fantis

      #3
      Re: Form / Subform Problems loading Data

      Thanks for your comments. I originally started out with StudentID in
      the application table. Turns out it would have been too much of a head
      ache the way I was going. I am still going to keep the 2 tables, I know
      that I don't have to, but I will. Almost have it sussed, but should I
      have further problems, the you may see another posting.



      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      Working...