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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Me.Visible = false not working 2

Status
Not open for further replies.

DajTwo

Technical User
Jul 17, 2008
157
US
I have been trying to improve the speed of my database by implementing a Persistent Connection as per my post
thread705-1524118 where PHV (great thanks) provided help.

In order for the persistent connection to work, Ineed to keep this form open hit INvisible.

I have been trying several ways to make the form invbisible to no avail. The form is currently opened by the 'StartUp' function under the Tool menu.

Can someone tell me where I am makign the error? Thanks!

Private Sub Form_Open(Cancel As Integer)

OpenAllDatabases True

On Error GoTo ErrorHandler

Dim StrVerClient As String
Dim StrVerServer As String
Dim stDocName As String
Dim stLinkCriteria As String

' Populate module level variables when form loads.
StrVerClient = Nz(DLookup("[ver_clt]", "[tbl_version_client]"), "")
StrVerServer = Nz(DLookup("[ver_ser]", "[tbl_version_server]"), "")

If (StrVerClient <> StrVerServer) Then
MsgBox "Your version of WAD is not up to date, please contact your database administrator", vbOKOnly, "Outdated WAD version"

Me.Visible = False

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

Else

Me.Visible = False

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

End If

ExitHere:
Exit Sub

ErrorHandler:

MsgBox "Take note of the error number and description" & vbCrLf & Err.Number & vbCrLf & Err.Description & vbCrLf & "Contact your database administator with that information", vbOKOnly, "Unplanned Error"

Resume ExitHere


End Sub


If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
DajTwo . . .

You can use an [blue]AutoExec[/blue] macro. This macro runs whenever you open the DB:
[ol][li]Remove the form from the startup dialog.[/li]
[li]Goto the [blue]Macros[/blue] window. Select [blue]new[/blue].[/li]
[li]When your in the macro grid select [blue]save[/blue] and assign [blue]AutoExec[/blue] as the macro name (it has to be [blue]AutoExec[/blue]).[/li]
[li]In the top line under the action column select [blue]OpenForm[/blue]. At the bottom left you'll see the parameters. Select the [blue]FormName, View, and Window mode (they're all comboboxes)[/blue].[/li]
[li]On the next [blue]Action[/blue] line select [blue]StopMacro[/blue].[/li]
[li]Save, close the macro, close the DB and perform your testing ...[/li][/ol]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks PHV and Aceman!!

The form is no longer there.. and since the msgbox functionnnality is working, I assume that the form is still working and hidden

The Autoexec did the trick with

Private Sub Form_Open(Cancel As Integer)
Me.Visible = False
End Sub





If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
Well I spoke too soon.

Still appears, the testing was done while I left an old docmd.close command for testing other stuff.

I am going to try to have the AutoExec macro open a function where the open form achidden code will be.

Will see if that works

If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
I created a Module with the following code

Sub OpenVerCheck()

DoCmd.OpenForm "system_version_check", acNormal, , , , acHidden

End Sub

The Autoexec Macro is
OpenModule : basStart
Procedure Name : OpenVerCheck

The Open event of the form is

Private Sub Form_Open(Cancel As Integer)

OpenAllDatabases True

Dim StrVerClient As String
Dim StrVerServer As String
Dim stDocName As String

StrVerClient = Nz(DLookup("[ver_clt]", "[tbl_version_client]"), "")
StrVerServer = Nz(DLookup("[ver_ser]", "[tbl_version_server]"), "")

If (StrVerClient <> StrVerServer) Then
MsgBox "Your version of WAD is not up to date, please contact your database administrator", vbOKOnly, "Outdated WAD version"

stDocName = "menu_main"
DoCmd.OpenForm stDocName

End Sub

On testing, the AutoExec works, but the module windows opens showing the code (?), and the form program is not running as the msbbox is not being displayed.



If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
Make it a function instead of a Sub

[pipe]
Daniel Vlas
Systems Consultant

 
Good idea,

Tried it but did not work.

Something has to give, my head or this darn database.. :)



If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
Well... a hybrid solution:

Create a blank form (frmInit) that has the following OnLoad procedure:

DoCmd.OpenForm "YourDesiredForm", , , , , acHidden
DoCmd.Close acForm, Me.Name


Place frmInit in Startup.
It works (I've tested it): The form opens, executes the OnLoad procedure, opens your form HIDDEN, then closes itself as if nothing happened.

HTH


[pipe]
Daniel Vlas
Systems Consultant

 
Hi danvlas.

I was thinking in the same line last night.

I proceeded to do what you suggested.

Private Sub Form_Load()
DoCmd.OpenForm "system_version_check", , , , , acHidden
DoCmd.Close acForm, frminit
End Sub

Now I cant close the frminit.. If I remove DoCmd.Close acForm, frminit then the from is hidden, execute the code and all is fine other than the frminit is on the screen.

I am trying other ways to get frminit to close ..

If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
I am starting to think that i am cursed (or an idiot :):) )

Cant close the frm init.

Tried in the hidden form, in the frminit, on open, on load, and several other places..

No idea at all..

If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
Again, why another form or procedure ?
A single Openform action with correct parameters in your AutoExec macro should suffice, doesn't it ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I read you PHV, but I could not make it work.

The AutoExec is setup to open the form as hidden (window mode).

When the database is opened, the code in the system_version_check form is not being ran and the screen is empty.

If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
I tried again re-writing the code fromn the start..

Must have had a bug somewhere cause logic has prevailed as PHV stated.

All works as it was supposed to 10 work hours ago..

Thanks for all your ideas, they were informative.. I have learned that redoing stuff is not a waste of time.

Thanks again


If I did not say it before, I really appreciate the time and expertise of the users on this forum.
 
Not sure if you have solved this problem yet, but I was trying to do the same thing in Word. VBA doesn't allow Me.Visible = True, but it does allow Me.Hide. Worked in Word, should work in Access as well. When you want to make the form visable again, use Me.Show or <formname>.Show from some other code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top