dbTalk Databases Forums  

Why can't I hide a form

comp.databases.ms-access comp.databases.ms-access


Discuss Why can't I hide a form in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Phil
 
Posts: n/a

Default Why can't I hide a form - 10-06-2010 , 05:39 PM






Snippet of code

ElseIf [Type] = -32768 Then ' forms
DoCmd.OpenForm ObjName, , , , acFormReadOnly, acHidden
Set Frm = Forms(ObjName)
Call MergeAllWord("", Frm.RecordsetClone)
Set Frm = Nothing
DoCmd.Close acForm, ObjName
End If

On th OnOpen event of the form I have

Private Sub Form_Open(Cancel As Integer)

DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore

End Sub

As you can see on the first snippet, I need to get the form' recordset for
passing to a mail merge function.... Perfect But why is the form showing when
I open it acHidden? Access 2010
Thanks

Phil

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Why can't I hide a form - 10-06-2010 , 07:30 PM






Phil wrote:

Quote:
Snippet of code

ElseIf [Type] = -32768 Then ' forms
DoCmd.OpenForm ObjName, , , , acFormReadOnly, acHidden
Set Frm = Forms(ObjName)
Call MergeAllWord("", Frm.RecordsetClone)
Set Frm = Nothing
DoCmd.Close acForm, ObjName
End If

On th OnOpen event of the form I have

Private Sub Form_Open(Cancel As Integer)

DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore

End Sub

As you can see on the first snippet, I need to get the form' recordset for
passing to a mail merge function.... Perfect But why is the form showing when
I open it acHidden? Access 2010
Thanks

Phil
Don't know why. I added this code to the OnActivate event
Private Sub Form_Activate()
If NZ(Me.OpenArgs, "") <> "Hidden" Then DoCmd.Restore
End Sub

And a code mod with the following
Sub Test
DoCmd.OpenForm "MyFormName", , , , , acHidden, "Hidden"
MsgBox "Test"
DoCmd.Close acForm, "MyFormName"
End Sub

If "Hidden" I see the msgbox only. If "Hidden1" I see the form and
messagebox. Maybe the "Restore" affects it.

Reply With Quote
  #3  
Old   
Phil
 
Posts: n/a

Default Re: Why can't I hide a form - 10-07-2010 , 03:23 AM



On 07/10/2010 01:30:34, Salad wrote:
Quote:
Phil wrote:

Snippet of code

ElseIf [Type] = -32768 Then ' forms
DoCmd.OpenForm ObjName, , , , acFormReadOnly, acHidden
Set Frm = Forms(ObjName)
Call MergeAllWord("", Frm.RecordsetClone)
Set Frm = Nothing
DoCmd.Close acForm, ObjName
End If

On th OnOpen event of the form I have

Private Sub Form_Open(Cancel As Integer)

DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore

End Sub

As you can see on the first snippet, I need to get the form' recordset for
passing to a mail merge function.... Perfect But why is the form showing when
I open it acHidden? Access 2010
Thanks

Phil

Don't know why. I added this code to the OnActivate event
Private Sub Form_Activate()
If NZ(Me.OpenArgs, "") <> "Hidden" Then DoCmd.Restore
End Sub

And a code mod with the following
Sub Test
DoCmd.OpenForm "MyFormName", , , , , acHidden, "Hidden"
MsgBox "Test"
DoCmd.Close acForm, "MyFormName"
End Sub

If "Hidden" I see the msgbox only. If "Hidden1" I see the form and
messagebox. Maybe the "Restore" affects it.


Thanks Salad

Put me on the right track

The OpenForm is now

DoCmd.OpenForm ObjName, , , , acFormReadOnly, acHidden, "Hidden"

and the OnOpen becomes

Private Sub Form_Open(Cancel As Integer)

If Nz(Me.OpenArgs, "") <> "Hidden" Then
DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore
End If

End Sub

Heaven help me, I may have to do the OnOpen mod to every form & report in the
Db (250 less the subforms & reports). Keep me amused for a bit

Thanks again

Phil

Reply With Quote
  #4  
Old   
David-W-Fenton
 
Posts: n/a

Default Re: Why can't I hide a form - 10-07-2010 , 08:20 PM



"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote in
news:i8itqt$edv$1 (AT) speranza (DOT) aioe.org:

Quote:
Private Sub Form_Open(Cancel As Integer)

DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore

End Sub
Why not:

Private Sub Form_Open(Cancel As Integer)
If Me.Visible Then
DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore
End If
End Sub

Then you don't have to muck about with OpenArgs.

Note that the acHidden switch is the same as setting the form's
Visible property, which is why the above should work.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
  #5  
Old   
Phil
 
Posts: n/a

Default Re: Why can't I hide a form - 10-08-2010 , 03:35 AM



On 08/10/2010 02:20:24, "David-W-Fenton" wrote:
Quote:
"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote in
news:i8itqt$edv$1 (AT) speranza (DOT) aioe.org:

Private Sub Form_Open(Cancel As Integer)

DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore

End Sub

Why not:

Private Sub Form_Open(Cancel As Integer)
If Me.Visible Then
DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore
End If
End Sub

Then you don't have to muck about with OpenArgs.

Note that the acHidden switch is the same as setting the form's
Visible property, which is why the above should work.

Thanks David

That also works. Just a pain in the Ar.. having to key it in for some 100
forms. I had expected that if a form was opened acHidden, it would stay that
way unless it was closed and re-opened in another WindowMode.

Ah well

Phil

Reply With Quote
  #6  
Old   
Salad
 
Posts: n/a

Default Re: Why can't I hide a form - 10-08-2010 , 11:11 AM



Phil wrote:
Quote:
On 08/10/2010 02:20:24, "David-W-Fenton" wrote:

"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote in
news:i8itqt$edv$1 (AT) speranza (DOT) aioe.org:


Private Sub Form_Open(Cancel As Integer)

DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore

End Sub

Why not:

Private Sub Form_Open(Cancel As Integer)
If Me.Visible Then
DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore
End If
End Sub

Then you don't have to muck about with OpenArgs.

Note that the acHidden switch is the same as setting the form's
Visible property, which is why the above should work.



Thanks David

That also works. Just a pain in the Ar.. having to key it in for some 100
forms. I had expected that if a form was opened acHidden, it would stay that
way unless it was closed and re-opened in another WindowMode.

Ah well

Phil
I tried this
Sub xyz()
DoCmd.OpenForm "MyForm", , , , , acHidden
Forms!MyForm.Form.Visible = False
DoCmd.OpenForm "AnotherForm"
End Sub

It worked fine. Only "AnotherForm" was visible. I didn't do any
testing on the "set" statements you have.

Maybe that will work if you have a common code snippet.

Reply With Quote
  #7  
Old   
Phil
 
Posts: n/a

Default Re: Why can't I hide a form - 10-08-2010 , 02:49 PM



On 08/10/2010 17:11:45, Salad wrote:
Quote:
Phil wrote:
On 08/10/2010 02:20:24, "David-W-Fenton" wrote:

"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote in
news:i8itqt$edv$1 (AT) speranza (DOT) aioe.org:


Private Sub Form_Open(Cancel As Integer)

DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore

End Sub

Why not:

Private Sub Form_Open(Cancel As Integer)
If Me.Visible Then
DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore
End If
End Sub

Then you don't have to muck about with OpenArgs.

Note that the acHidden switch is the same as setting the form's
Visible property, which is why the above should work.



Thanks David

That also works. Just a pain in the Ar.. having to key it in for some 100
forms. I had expected that if a form was opened acHidden, it would stay that
way unless it was closed and re-opened in another WindowMode.

Ah well

Phil

I tried this
Sub xyz()
DoCmd.OpenForm "MyForm", , , , , acHidden
Forms!MyForm.Form.Visible = False
DoCmd.OpenForm "AnotherForm"
End Sub

It worked fine. Only "AnotherForm" was visible. I didn't do any
testing on the "set" statements you have.

Maybe that will work if you have a common code snippet.

To the rescue again

Form shows briefly and then vanishes. That's fine

Thanks

Phil

Reply With Quote
  #8  
Old   
Salad
 
Posts: n/a

Default Re: Why can't I hide a form - 10-08-2010 , 04:00 PM



Phil wrote:

Quote:
On 08/10/2010 17:11:45, Salad wrote:

Phil wrote:

On 08/10/2010 02:20:24, "David-W-Fenton" wrote:


"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote in
news:i8itqt$edv$1 (AT) speranza (DOT) aioe.org:



Private Sub Form_Open(Cancel As Integer)

DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore

End Sub

Why not:

Private Sub Form_Open(Cancel As Integer)
If Me.Visible Then
DoCmd.SelectObject acForm, Me.Name
DoCmd.Restore
End If
End Sub

Then you don't have to muck about with OpenArgs.

Note that the acHidden switch is the same as setting the form's
Visible property, which is why the above should work.



Thanks David

That also works. Just a pain in the Ar.. having to key it in for some 100
forms. I had expected that if a form was opened acHidden, it would stay that
way unless it was closed and re-opened in another WindowMode.

Ah well

Phil

I tried this
Sub xyz()
DoCmd.OpenForm "MyForm", , , , , acHidden
Forms!MyForm.Form.Visible = False
DoCmd.OpenForm "AnotherForm"
End Sub

It worked fine. Only "AnotherForm" was visible. I didn't do any
testing on the "set" statements you have.

Maybe that will work if you have a common code snippet.



To the rescue again

Form shows briefly and then vanishes. That's fine

Thanks

Phil
Yeah. I was running it from the immediate window so I didn't see it but
I figured it would if running from a form. I guess Restore or Maximize
resets the visible property.

Reply With Quote
  #9  
Old   
David-W-Fenton
 
Posts: n/a

Default Re: Why can't I hide a form - 10-08-2010 , 08:49 PM



Salad <salad (AT) oilandvinegar (DOT) com> wrote in
news:SJmdnXahSsMbGzLRnZ2dnUVZ_uSdnZ2d (AT) earthlink (DOT) com:

Quote:
I guess Restore or Maximize
resets the visible property.
....which is why you want to skip running restore/maximize if the
form is not visible, as in the code I posted.

There isn't anything complicated here.

And, in fact, I'd suggest it's better to write a function for
opening any generic form and restore/maximize that can handle
opening hidden, too. That way, you don't need code in each form to
deal with it.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
  #10  
Old   
Phil
 
Posts: n/a

Default Re: Why can't I hide a form - 10-09-2010 , 03:44 AM



On 09/10/2010 02:49:12, "David-W-Fenton" wrote:
Quote:
Salad <salad (AT) oilandvinegar (DOT) com> wrote in
news:SJmdnXahSsMbGzLRnZ2dnUVZ_uSdnZ2d (AT) earthlink (DOT) com:

I guess Restore or Maximize
resets the visible property.

...which is why you want to skip running restore/maximize if the
form is not visible, as in the code I posted.

There isn't anything complicated here.

And, in fact, I'd suggest it's better to write a function for
opening any generic form and restore/maximize that can handle
opening hidden, too. That way, you don't need code in each form to
deal with it.

Agreed David, but it's the fag of modifying well over 100 forms - but I'll
get round to it. The generic function you suggest would have to be called on
the OnOpen of every form I presume

Phil

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.