What is the best time to fire an onload event in data access page?

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

    What is the best time to fire an onload event in data access page?

    All,

    I'm looking for the best time to fire an onload save record event.

    I currently have the following:

    Code:
    <SCRIPT language=vbscript event=onload for=window>
    <!--
    
    
    Call hi
    
    -->
    </SCRIPT>
    
    
    <SCRIPT language=vbscript>
    
    Sub hi()
    msgbox "hi"
    MSODSC.Datapages(0).Save
    end sub
    
    </SCRIPT>

    However as you can see I have had to put a msgbox in for the code to execute correctly. If i remove the messagebox the event seems to fire too early before the page has fully loaded.

    I could use a timer but my datapage may take a while to load up for some users with a poor connection so it is not 100% bullet proof.

    Any suggestions on where I can get this to fire?
  • munkee
    Contributor
    • Feb 2010
    • 374

    #2
    Quick reply here since I have moved on a bit and got so confused now!

    I basically want to save a record as soon as the data access page loads FULLY.

    I can get the page to save perfectly fine using the following code:


    Code:
    <script language=vbscript event=onload for=window>
    
    call hi
    
    </script>
    
    <SCRIPT language=vbscript>
    
    Sub hi()
    msgbox "just to delay"
    MSODSC.Datapages(0).Save
    end sub
    
    </SCRIPT>
    However, if i remove the msgbox to delay the save the record no longer saves. It is as if it is firing too early before the record is ready. This is exactly the same with all commands (moving record or creating new).

    Does anyone know how i can get past this? I would use a delay script but i'm unsure whether this is a bulletproof

    Thanks Chris

    Comment

    • munkee
      Contributor
      • Feb 2010
      • 374

      #3
      Sorted this now, got the event to fire when the focus is taken on one of my text boxes as soon as the page loads onload event is really annoying to work with so this is the best other option.

      Comment

      Working...