Help required in Form Timer function

zonexs123

Registered User.
Local time
Tomorrow, 01:54
Joined
Feb 6, 2011
Messages
39
Hi All,

I have a database (sample attached) with three forms:
1) Startup (Flash screen type, will close in 5 secs)
2) MainMenu2 (will be open after flash screen close)
3) MainMenu1

Want help in opening these forms (MainMenu2 or MainMenu1) after Startup form close only when some criteria met. Criteria should be if today date is lesser then 02/04/2012 then open form MainMenu2 or esle it should open MainMenu1.

I try all over the net but not success. Even coded in Startup form Form_Timer() but failed. Your help would be appericated.


Thanks,
Santosh
 

Attachments

Put the code in th Close event of the Startup form:
Code:
If Date < CDate("2 April 2012") Then
    .... open MainMenu2 code should go here ...
Else
    .... open MainMenu1 code should go here ...
End If
By the way, why do you need to open different forms based on that date? Are they not the same form?

I'm guessing you already have code for closing the startup form after 5 seconds.
 
Thanks for your prompt response and helping out however I'm still stuck here and getting compile error:

"Can't find project or library"

Here is my code (in my Startup from):

Private Sub Form_Close()
If Date < CDate("2 January 2012") Then
DoCmd.OpenForm "MainMenu2"
Else
DoCmd.OpenForm "MainMenu1"
End If
End Sub

I don't know what getting wrong here...
Also, both the form (MainMenu2 & MainMenu1) has different purpose after some given time....

Your help required to work it out...

Thanks again....
 
When you click Debug what code line does it highlight in yellow?
 
On Date (just after If) in following line:

If Date < CDate("2 January 2012") Then
 
What about using this:

If Date < VBA.CDate("2 January 2012") Then
 
Still something going wrong... I am getting the same error... however once I click the ok button its open the References window to check or uncheck available references.

Please advise...
 
Something has gone wrong with your references. Open up the References window and untick the ones that read "MISSING:".

Or

Create a new database and import all your objects (i.e. tables, queries, forms, reports, macros) into it.
 
I un-ticked the ones that read "MISSING:" references and now there is no any debug error however following code open both the forms (MainMenu1 & MainMenu2) and on front its shows MainMenu2 when today date is greater than "2 January 2012". but still MainMenu1 is shows opened.

Its working fine when today date is lesser than "2 January 2012" and not showing form MainMenu1 opened.

Here is the final code...

Private Sub Form_Close()
If Date < VBA.CDate("2 January 2012") Then
DoCmd.OpenForm "MainMenu2"

Else
DoCmd.OpenForm "MainMenu1"

End If
End Sub

Please see the attached file with above code added. --- =

Please Advise.....

Thanks in advance... :)
 

Attachments

Last edited:
Thanks for the hint... I moved the code from "Close Form" event to "Form_Timer" event and its working exactly what I was willing....

Thank you soooooooo.... much dear. You guys are great in Access :)
 
You're welcome! :)
Thanks for the hint... I moved the code from "Close Form" event to "Form_Timer" event and its working exactly what I was willing....
That's a good thought but what I was actually hinting on is that you remove the OpenForm code in the Timer event and leave the code in the On Close event. Everything should have run as expected too. It's more logic to put it in the Close or UnLoad event than in the Timer event.
 

Users who are viewing this thread

Back
Top Bottom