Commands in start-up forms

GeorgeChr

Registered User.
Local time
Today, 13:56
Joined
Jun 26, 2007
Messages
24
First of all I want to thank everyone here because before I was a total catastrophe with access and now I'm becoming an expert I think! But now I have some more complicated questions for you guys! here it goes:
I have a welcome form that pops up when you open the DB and it has username identification, a running clock and a "close" command.
Now, I want to do 2 more things:
1) create a code that will make this form automatically close after 10 seconds without having problems with the clock (because they both execute at the "on time" event of the form i think).
2) I want to make the switchboard open right after the form is automatically closed and I also want to create a button/command where someone can manually open the S/B (without waiting 10 secs) but also when it opens the S/B, the form must close!!
I hope that you guys know these answers!! Thank You all once again
 
In the Form - put in the Form_Load event:

Me.Timer - 10000 ' 1 second = 1000

In the From_Timer event put

Docmd.OpenForm "Switchboard"
Docmd.Close acform, "Form1" ' this will close it after 10 seconds.


Put a command button on your Form and in its On_Click event put

Docmd.OpenForm "Switchboard"
Docmd.Close acform, "Form1"



As these two lines of code are the same, rather than entering them twice you could but them in a little Function routine but for 2 lines its not worth it.
 
ted thank you very much, the second code worked perfectly and i can now open the S/B and have the form automatically closed. The first one I still have problems..
If you dont mind i attach the code so that you can tell me where exactly i should place the code. thanks though!

Private Sub Form_Load()

End Sub

Private Sub Form_Timer()
Me!lblClock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm:ss AMPM")
End Sub


Private Sub cmdClockStart_Click()
Me.TimerInterval = 1000
End Sub

Private Sub cmdClockEnd_Click()
Me.TimerInterval = 0
End Sub

Private Sub lblClose_Click()
On Error GoTo Err_lblClose_Click


' Close the splash screen &
' Open the main database form, frmMain

DoCmd.Close


Exit_lblClose_Click:
Exit Sub

Err_lblClose_Click:
MsgBox Err.Description
Resume Exit_lblClose_Click

End Sub

Private Sub Go_To_Switchboard_Click()
DoCmd.OpenForm "Switchboard"
DoCmd.Close acForm, "welcome"
On Error GoTo Err_Go_To_Switchboard_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Switchboard"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Go_To_Switchboard_Click:
Exit Sub

Err_Go_To_Switchboard_Click:
MsgBox Err.Description
Resume Exit_Go_To_Switchboard_Click

End Sub
 
Set your Timer Interval to 1000 then replace your Form_Timer() event with this:

Code:
Private Sub Form_Timer()
Static Counter As Integer
Counter = Counter + 1
Me!lblClock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm:ss AMPM")
If Counter = 10 Then
  DoCmd.OpenForm "Switchboard" 'this will open after 10 seconds.
  DoCmd.Close acForm, "Form1" ' this will close it after 10 seconds.
End If
End Sub
Good Luck!
 

Users who are viewing this thread

Back
Top Bottom