Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 detect if a form is in printpreview mode

Author  Topic 

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-05-13 : 03:31:25
Is there a way to detect which mode the form is in?

Ie, if the user does a print-preview on the form, can I do something during the Open event (or other) to change something about the way the form is displayed?

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-05-13 : 06:59:41
Are you referring me.Modal?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-05-16 : 19:33:37
No
quote:
print-preview

I need to know whether the form is in print preview mode.

Anyone else?

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-05-16 : 22:01:53
Found it - in case anyone wants or needs to know.

Public Function InPrintMode(f as Form) as boolean
Dim p as property
For each p in f.properties
if p.Name = "Pages" then
InPrintMode = True
Exit For
End if
Next p
End Function


Why did I need to know? - because if you try and setfocus to an enabled control on a form which is in printpreview mode, you'll get an error. So now I can check before setting focus.



--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-05-16 : 22:16:50
you can always use the good old "ON ERROR RESUME NEXT" too!

- Jeff
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-05-16 : 22:23:32
Thanks Jeff, however since the code to set the focus was generic for all forms, I'd like to be able to identify what error is actually happening and avoid it. Using the On Error Resume Next is fine for hiding errors, but if there's a different error occurring you may never know what is actually going wrong.

While we're on the topic - do you know how to detect whether a form has a user defined property (Get and Let type property)? It won't show in the properties collection. At the moment the only way I can tell is to try to reference it and see if I get an error. Any better suggestions?

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-05-16 : 23:00:15
PS - and besides, my mum always told me its polite to ask first

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

jhermiz

3564 Posts

Posted - 2005-05-18 : 19:01:40
You can case out error codes, do not use the ON ERROR RESUME NEXT it will bite later on. If a specific error code happens such as Err.Number = 20 then ... print something else...do the normal error printing routine.

Also you can create your own properties so I'm not sure what you mean with let and set.


Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]
Imperfection living for perfection --
[url]http://jhermiz.blogspot.com/[/url]
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-05-18 : 19:24:06
thanks j -

do you know how to detect whether a form has a user defined property ?


--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-06-02 : 21:15:52
just feeding back in case anyone wants to know:

You can tell if the form is opened printpreview mode, by checking for the existence of the .pages property, however there appears to be no catchable event which occurs when an opened form is printpreviewed.

In the end, I removed the print menu option in my application, and substituted "my own", which sets a form user defined property called .PrintMode() so I can tell which way to display my form.

There must of course, be some way to tell, perhaps through an API call using the form's handle (hwnd), so if anyone can tell me how, I'd still love to know...

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page
   

- Advertisement -