Data access page. Can not update sub form until main record saved.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • munkee
    Contributor
    • Feb 2010
    • 374

    #1

    Data access page. Can not update sub form until main record saved.

    This is something which is really bugging me, I can see why it happens but not how to fix it.


    Basically I have a data acces page with a main form.

    This main form then contains a sub form within a group section. I have the subform autoset to expand so it looks just the same as the rest of the form after some design changes.

    The main form basically looks as follows:

    Code:
    Caption - tblLog
    
    header - tblLog
    
    header - tblCosts
    navigation - tblCosts
    
    footer - tblLog
    navigation -tblLog
    As you can see this allows me to be able to view/navigate tblCosts associated with tblLog.

    This works fine for records that currently exist.

    However when I add a new record I produce a unique ID number for tblLog (main part) correctly. However, tblCosts subform will not expand and remains hidden.

    In order for me to display the subForm (or atleast a button to allow an addition to it) I have to save the main record.

    I assume this is so within my database I fully create the relationship between my main table and my sub table. When I save the ID number from the main table links to the sub and costs can then be added.


    I am a bit stuck because I am basically creating a submission form for non conformances and their associated costs. This will be hosted on an intranet allowing users to submit their information.

    What I am worried about happening is that when users partially fill out the form if I create an event which uses some form of OnDirty etc to save the main form to allow sub form submission I could end up with partial data or masses of rows within my main table where users began to fill out a form and then left the page when they decided not to bother.

    So all in all,

    How could I get my subform to display? I don't understand how when I create a new record the ID number assigns correctly to the main form, (I can even close the window and it doesn't save the record, it only saves when I click submit) but the subform does not expand ready for datacapture, eventhough there is a direct link.


    Thanks for any help.
  • munkee
    Contributor
    • Feb 2010
    • 374

    #2
    Originally posted by munkee
    This is something which is really bugging me, I can see why it happens but not how to fix it.


    Basically I have a data acces page with a main form.

    This main form then contains a sub form within a group section. I have the subform autoset to expand so it looks just the same as the rest of the form after some design changes.

    The main form basically looks as follows:

    Code:
    Caption - tblLog
    
    header - tblLog
    
    header - tblCosts
    navigation - tblCosts
    
    footer - tblLog
    navigation -tblLog
    As you can see this allows me to be able to view/navigate tblCosts associated with tblLog.

    This works fine for records that currently exist.

    However when I add a new record I produce a unique ID number for tblLog (main part) correctly. However, tblCosts subform will not expand and remains hidden.

    In order for me to display the subForm (or atleast a button to allow an addition to it) I have to save the main record.

    I assume this is so within my database I fully create the relationship between my main table and my sub table. When I save the ID number from the main table links to the sub and costs can then be added.


    I am a bit stuck because I am basically creating a submission form for non conformances and their associated costs. This will be hosted on an intranet allowing users to submit their information.

    What I am worried about happening is that when users partially fill out the form if I create an event which uses some form of OnDirty etc to save the main form to allow sub form submission I could end up with partial data or masses of rows within my main table where users began to fill out a form and then left the page when they decided not to bother.

    So all in all,

    How could I get my subform to display? I don't understand how when I create a new record the ID number assigns correctly to the main form, (I can even close the window and it doesn't save the record, it only saves when I click submit) but the subform does not expand ready for datacapture, eventhough there is a direct link.


    Thanks for any help.
    Well I have solved this one!


    Firstly in order to ensure the cost subform displays the record has to be saved on loading the window. I have just finished the code and here it is:

    Code:
    <SCRIPT language=vbscript event=onload for=window>
    <!--
    
    
    Call hi
    
    -->
    </SCRIPT>
    
    <SCRIPT language=vbscript>
    
    Sub hi()
    msgbox "hi"
    MSODSC.CurrentSection.DataPage.NewRecord
    msgbox "hi"
    MSODSC.CurrentSection.DataPage.Save
    end sub
    
    </SCRIPT>
    The msgbox bits are there as code stops as I need to sort some timers to ensure they execute on time.

    For everyone looking to display a new record everytime the page loads and do not want to use the DataEntry mode the code above will work for that.

    Now the hard part which I am yet to finish coding but I think i can now is, what to do if a user decides to just close the form? I have already saved the record so I need a way to ensure that I do not end up with loads of crap data in my database.

    So, I created a hidden checkbox. This checkbox is linked to my submit button. When the user clicks the submit button it puts a tick in the checkbox, saves the record + confirms saving.

    However, if there is no tick in the checkbox i.e. no user has clicked submit, upon closing the window on the window unload event i do a record delete. This removes the half filled out record.

    Comment

    Working...