ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Only Show User Form Once (https://www.excelbanter.com/excel-programming/286380-only-show-user-form-once.html)

cornishbloke[_8_]

Only Show User Form Once
 
Hi, once again I turn to this forum for help!

I have a workbook template (*.xlt) which, upon opening displays a
userform ("Quote_Details") into which the user enters details
(contractor name, quote number etc) of the quote they are about to
create. Once completed and the OK button is pressed this information
is sent to various places in the workbook, including headers, footers
and various cells.

The problem is that after the quote has been completed and saved it
still shows the "Quote_Details" userform upon opening.

I need the userform to only appear the first time a copy of the
template is opened and not after the copy has been named and saved. Is
this possible?

Any suggestions would be greatly appreciated.


---
Message posted from http://www.ExcelForum.com/


David Coleman

Only Show User Form Once
 
Hi

There's a couple of things you could add in to the macro to determine
whether to show the userform or not...

Assuming that the quote number is inserted in cell A1 and is blank until the
user has completed the required details you could do:

if (range("A1").value="") then quote_details.show

Then when the quote number gets written to A1 (i.e. once the user has
finished with the form). Variations on this include reserving cell "A50000"
(or similar) for a system only use cell - set it to TRUE if the form needs
showing or FALSE once the details have been completed

if range("A50000") then quote_details.show

Hope this helps

David



"cornishbloke" wrote in message
...
Hi, once again I turn to this forum for help!

I have a workbook template (*.xlt) which, upon opening displays a
userform ("Quote_Details") into which the user enters details
(contractor name, quote number etc) of the quote they are about to
create. Once completed and the OK button is pressed this information
is sent to various places in the workbook, including headers, footers
and various cells.

The problem is that after the quote has been completed and saved it
still shows the "Quote_Details" userform upon opening.

I need the userform to only appear the first time a copy of the
template is opened and not after the copy has been named and saved. Is
this possible?

Any suggestions would be greatly appreciated.


---
Message posted from http://www.ExcelForum.com/




Bob Phillips[_6_]

Only Show User Form Once
 
Cornish,

Suggestion.

Write a flag/switch to the registry when that form completes. In your
workbook open code, test the flag in the registry, if set, don't show the
form. You can use GetSetting and SaveSetting as simple registry read/writes.
The flag could be set with#

SaveSetting appname:="MyApp", _
section:=ActiveWorkbook.Name, _
key:="FirstTime", _
setting:="False"

and the open code would be something like

Private Sub Workbook_Open()
Dim sFlag As String

On Error Resume Next
sFlag = GetSetting(appname:="MyApp", _
section:=ActiveWorkbook.Name, _
key:="FirstTime")
On Error GoTo 0

If sFlag < "False" Then
Quote_Details.Show
End If

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"cornishbloke" wrote in message
...
Hi, once again I turn to this forum for help!

I have a workbook template (*.xlt) which, upon opening displays a
userform ("Quote_Details") into which the user enters details
(contractor name, quote number etc) of the quote they are about to
create. Once completed and the OK button is pressed this information
is sent to various places in the workbook, including headers, footers
and various cells.

The problem is that after the quote has been completed and saved it
still shows the "Quote_Details" userform upon opening.

I need the userform to only appear the first time a copy of the
template is opened and not after the copy has been named and saved. Is
this possible?

Any suggestions would be greatly appreciated.


---
Message posted from http://www.ExcelForum.com/




COM

Only Show User Form Once
 
Only problem with using registry entries, is that if the file is moved to another computer, or accessed by a different logged in user, then the registry values will not be present, or at least not the same. This depends on your forseeable use of the program, and forecasting how your "company" will work in the future. A more robust method would be suggested, as one a company could change it's method of doing business at any time, and no reason to lose out on a well written program by a thoughtful programmer.. I think it looks better to be someone that plans for change and remembered for the good quality of work, rather than someone that has caused great losses by not thinking ahead. Of course helps even more if others understand the problem faced, and see/recognize how you were able to overcome it.

A little social engineering thrown into this vast world of computer programming.


Tomek[_3_]

Only Show User Form Once
 
I'd rather do it the way David suggested, use a cell I'd be sure that it
won't be needed to enter any data into. Using registry for this purpose is a
misuse of it, it contains much too much garbage to put even more in it.
Besides, keeping the flag in the workbook will ensure that the user form
won't show even if You open the workbook on another machine, registry won't.





All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com