very odd problem with form load and Date()

Zaeed

Registered Annoyance
Local time
Today, 17:04
Joined
Dec 12, 2007
Messages
383
Hi, im just experimenting with creating a backup button that simply copys the backend and pastes it into a backup folder with the date attatched. Since I have not used the Date() function I did some testing by putting msgbox(Date()) into a forms load procedure.. That worked fine when i opened the form.. However, when i closed that form, the message box popped back up, i click ok, it pops back up etc etc :eek:

Any ideas whats going on here..
 
Copy your code here (the whole form) and include the event headers.
 
what are the event headers?
 
The things like:

Private Function YourCommandButton_Click()


etc.
 
Code:
Option Compare Database
Option Explicit


Private Sub Form_Close()
Form_MainMenu!MainMenu_subfrm.SourceObject = "frm_Login"
End Sub

Private Sub Form_Load()

    [COLOR="Red"]x=msgbox(Date())[/COLOR]

    'Sets the subform to be the login screen
    Form_MainMenu!MainMenu_subfrm.SourceObject = "frm_Login"

    'Hides the additional buttons
    If Form_MainMenu!MainMenu_subfrm.SourceObject = "frm_Login" Then
        Form_MainMenu!frm_MainMenu_Logout.Visible = False
        Form_MainMenu!frm_MainMenu_Exit.Visible = False
        Form_MainMenu!frm_MainMenu_MainMenu.Visible = False
    Else
        Form_MainMenu!frm_MainMenu_Logout.Visible = True
        Form_MainMenu!frm_MainMenu_Exit.Visible = True
        Form_MainMenu!frm_MainMenu_MainMenu.Visible = True
    End If
    
End Sub

Private Sub frm_MainMenu_Exit_Click()

    x = MsgBox("Are you sure you wish to quit?", vbYesNo, "Quit Confirm")
    
    If x = vbYes Then
       DoCmd.Quit
    End If
    
End Sub

Private Sub frm_MainMenu_Help_Click()

    Dim WordObj As Object
    Set WordObj = CreateObject("Word.Application")
    WordObj.Visible = True
    WordObj.Documents.Open "\\Pcmtd000125\ChangeDatabase\CMS User Guide.doc"
    
    Set WordObj = Nothing

End Sub

Private Sub frm_MainMenu_Logout_Click()

    UserName = Form_frm_Login!frm_Login_DropBox
    
    Form_MainMenu!MainMenu_subfrm.SetFocus
    Form_MainMenu!MainMenu_subfrm.SourceObject = "frm_Login"
    Form_MainMenu!MainMenu_subfrm.Requery
    Form_MainMenu!frm_MainMenu_Logout.Visible = False
    Form_MainMenu!frm_MainMenu_Exit.Visible = False
    Form_MainMenu!frm_MainMenu_MainMenu.Visible = False
End Sub

Private Sub frm_MainMenu_MainMenu_Click()

    Form_MainMenu!MainMenu_subfrm.SetFocus
    Form_MainMenu!MainMenu_subfrm.SourceObject = "frm_Menu"
    Form_MainMenu!MainMenu_subfrm.Requery
    Form_MainMenu!frm_MainMenu_Logout.Visible = True
    Form_MainMenu!frm_MainMenu_Exit.Visible = True
    Form_MainMenu!frm_MainMenu_MainMenu.Visible = False
     
End Sub
 
I'm guessing that "frm_Login" has some code that is referencing a control/value on the form you are working with (I don't think you mentioned the form's name), since your close event "makes" that the SourceObject of your sub-form variable.

Be assured that some code is re-opening your form, not necessarily code on this form. Your job is to find it. That might be hard because it looks like you've obscured your forms names by using objects to refer to them (hard to tell what's going on from this code snippet).
 

Users who are viewing this thread

Back
Top Bottom