Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009
    Location
    Gatineau, Quebec Canada
    Posts
    147
    Provided Answers: 1

    Unanswered: Limits on Startup Pages as Menu Pages

    Greetings all,

    Back from teaching in China, and way too much time on my hands. I have a program to deal with personal tasks and purchases. Thought it would be interesting if, on the startup page, I would see urgent purchase requirements (thought I might do the same thing with urgent tasks too). I tried the following code on both the form load and form open events:

    Private Sub Form_Open(Cancel As Integer)

    Dim aString As String
    Dim aCount As Integer
    Dim aSQL As String

    aCount = DCount("[item]", "grocery", "[urgent] = True")
    If (aCount < 1) Then

    aString = "Nothing urgent at the moment"
    Else

    Dim currCon As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Set currCon = CurrentProject.Connection
    DoCmd.SetWarnings False

    aSQL = "SELECT Item from grocery where urgent = TRUE"

    rs.Open aSQL, currCon, adOpenForwardOnly
    rs.MoveFirst
    Do While Not rs.EOF
    aString = aString & " -- " & rs("item")
    rs.MoveNext
    Loop


    End If


    DoCmd.SetWarnings True

    ' currCon.Close

    txtUrgent.Value = aString

    DoCmd.Maximize

    End Sub

    From within the program, I can mark an item as "urgent". When I do so, the code above works fine on a form that is not a startup page, however always misses the prior selection(s) on the startup page (which also contains the main menu) until the startup page is called a second time. Any idea why? Does a startup page have certain special qualities in terms of the form load and form open events? Can one not use a startup page for the main menu?

    Regards


    John S

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    there is nothing special about a startup form other than it is supposed to show when the application starts.
    _Load is later than _Open so should suit your purpose better.
    if _Load won't do it for you, consider a workaround:
    design-time set a timer (.timerinterval = 1 (millisecond) - should be enough)

    in the timer routine:
    a/ switch off the timer (.timerinterval = 0) ...so it only runs once (at startup)
    b/ fill your startup form

    when Access starts, the startup form loads fully BEFORE the timer starts ticking, so using the timer bypasses any timing issues that might be causing your problem.

    if you are already using the timer for other purposes, you can make a multi-purpose timer with a variable (iAmStarting Boolean) design-time set to true and in your timer code:
    if iAmStarting then
    me.timerinterval = 0
    iAmStarting = false
    else
    'whatever you were doing with the timer before
    endif

    izy
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •