![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 |
#3
| |||
| |||
|
|
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. |
#4
| |||
| |||
|
|
Private Sub Form_Open(Cancel As Integer) DoCmd.SelectObject acForm, Me.Name DoCmd.Restore End Sub |
#5
| |||
| |||
|
|
"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. |
#6
| |||
| |||
|
|
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 |
#7
| |||
| |||
|
|
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. |
#8
| |||
| |||
|
|
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 |
#9
| |||
| |||
|
|
I guess Restore or Maximize resets the visible property. |
#10
| |||
| |||
|
|
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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |