Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No "Visible" Option in Form Properties Window

Status
Not open for further replies.

Elysynn

Technical User
Mar 18, 2004
82
US
Hello,

I'm feeling particularly baffled this morning. I could have sworn there was a "Visible" option in the properties window for forms. I'm in Access 2003. Here is the simple task i am trying to accomplish...

When the database opens, frmOpen opens. I want frmOpen to be hidden. Simple, right? I thought so... This is something I've done numerous times before - granted the last time was about 6 months ago on Access 2002.

This is the code that I currently have attached to the form.
Code:
Private Sub Form_Open(Cancel As Integer)

Dim strLogStatus As String
Dim datLogDate As Date

gblUser = Environ("UserName")
strLogStatus = "In"
datLogDate = Now()

DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblUserLog(User, LogStatus, LogTime)" & _
             " VALUES ('" & gblUser & "', '" & strLogStatus & "', #" & datLogDate & "#);"
DoCmd.SetWarnings True

DoCmd.OpenForm "frmMenuMain"

End Sub

I've tried adding: Me.Forms.Visible = False to the codebefore the SQL runs. This didn't work. Please don't hesitate to point out the obvious... ;)

TIA,
Elysynn
 
Thanks for your reply Geoff. Unfortunately, it didn't work =(

Code:
Private Sub Form_Open(Cancel As Integer)

Dim strLogStatus As String
Dim datLogDate As Date

Me.Visible = False

gblUser = Environ("UserName")
strLogStatus = "In"
datLogDate = Now()

DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblUserLog(User, LogStatus, LogTime)" & _
             " VALUES ('" & gblUser & "', '" & strLogStatus & "', #" & datLogDate & "#);"
DoCmd.SetWarnings True

DoCmd.OpenForm "frmMenuMain"

End Sub

Am I correct in my understanding that there should be a [blue]Visible[/blue] selection in the properties window?

-Elysynn
 
How are ya ItIsHardToProgram . . .

Try moving your code to the [blue]On Load[/blue] event!
ItIsHardToProgram said:
[blue]Am I correct in my understanding that there should be a Visible selection in the properties window?[/blue]
No . . . Incorrect! . . . thats because the [blue]Visible[/blue] property for a form is [blue]only available at runtime[/blue] and why in VBA you'll see it . . .

Calvin.gif
See Ya! . . . . . .
 
Just tried the On Load event - still no dice...

[code}Private Sub Form_Load()

Me.Visible = False

End Sub
Private Sub Form_Open(Cancel As Integer)

Dim strLogStatus As String
Dim datLogDate As Date

gblUser = Environ("UserName")
strLogStatus = "In"
datLogDate = Now()

DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblUserLog(User, LogStatus, LogTime)" & _
" VALUES ('" & gblUser & "', '" & strLogStatus & "', #" & datLogDate & "#);"
DoCmd.SetWarnings True

DoCmd.OpenForm "frmMenuMain"

End Sub[/code]

I've tried it with both Me.Visible = False and Me.Form.Visible = False in the On Load event.

Thanks again for your help...

-Elysynn
 
Elysynn . . .

Just a quick shot here (I have to run Out).

I suspect there's code that opens this form where your code resides. Probably an DoCmd.OpenForm

Where this exist try:
Code:
[blue]DoCmd.OpenForm "YourFormName", , , , , [purple][b]acHidden[/b][/purple][/blue]

Calvin.gif
See Ya! . . . . . .
 
TheAceMan1: Thanks for helping out. There is no code that tells this form to open - it opens when the database opens using the properties in Tools -> Startup.

-Elysynn
 
Hi, Elysynn,

Just curious... What does frmOpen do? I mean, besides write the login data? If that is its only purpose, seems like this functionality could be moved to the "frmMenuMain" form. Or maybe create a splash screen form that doesn't need to be hidden.

Your thoughts?

Ken S.
 
Hi Ken,

The form frmOpen exists to capture both the login data and the logout as well. The second part of the code that I did not post has a similar procedure to write the user data to the table on the On Close event. I have it set up this way, so no matter how the user closes out of the database I have a record of them leaving. The form may also have additional functions in the future (such as a timer to auto-close the database).

I know that I could do this on the main menu or splash screen - I just feel this option is a little more flexible. I'm just frustrated because I know I've done this before, several times. I just don't have my previous work to reference how I did it.

-Elysynn
 
This one works for me:

DoCmd.OpenForm "frmYourForm", acNormal, "", "", , acHidden
 
Okay, you could try reversing the order of the opening forms, i.e. open frmMenuMain from startup, and in the first line of frmMenuMain's open, load, activate, whatever event, open frmOpen. Then you can use the acHidden argument of the DoCmd.OpenForm command...

HTH,

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top