08-09-10, 15:17 #1Registered User
Provided Answers: 1
- Join Date
- Mar 2009
- Gatineau, Quebec Canada
Unanswered: Limits on Startup Pages as Menu Pages
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"
Dim currCon As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set currCon = CurrentProject.Connection
aSQL = "SELECT Item from grocery where urgent = TRUE"
rs.Open aSQL, currCon, adOpenForwardOnly
Do While Not rs.EOF
aString = aString & " -- " & rs("item")
txtUrgent.Value = aString
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?
08-10-10, 14:39 #2Cavalier King Charles
- Join Date
- Dec 2002
- Préverenges, Switzerland
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
'whatever you were doing with the timer before
izycurrently using SS 2008R2