Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default Open Userform two ways

I've a userform that needs to be loaded in one of two scenarios ...

First, it may be used to MODIFY an existing entry ... so would be pre-
loaded using data passed from another userform.

Or, it could be used ADD a new entry ... so would be loaded with all
fields blank.

How do I tell the userform which way to load? I could test to see if
the other userform is loaded, but doing so would automatically load it
anyway, right?

Thoughts or ideas?

TIA,
Ray
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Open Userform two ways

One way is to create a public variable in a General module.

Set that as an indicator of what should be done. Then use that indicator
variable in the userform_initialize procedure.

option explicit
Public OpenFormModify as boolean
Sub ShowMyForm()
if something is true then
openformmodify = true
else
openformmodify = false
end if
End sub

And behind the userform:

Option Explicit
Private Sub UserForm_Initialize()
if openformmodify = true then
'initialize the form with a record
else
'initialize the form to add
end if
End Sub



Ray wrote:

I've a userform that needs to be loaded in one of two scenarios ...

First, it may be used to MODIFY an existing entry ... so would be pre-
loaded using data passed from another userform.

Or, it could be used ADD a new entry ... so would be loaded with all
fields blank.

How do I tell the userform which way to load? I could test to see if
the other userform is loaded, but doing so would automatically load it
anyway, right?

Thoughts or ideas?

TIA,
Ray


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default Open Userform two ways

Perfect! Thanks Dave ...

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Open Userform two ways

And if the number of choices is more than 2 (so you can't use boolean), you can
declare it as string or long or whatever and check that in the _initialize
event.

Dave Peterson wrote:

One way is to create a public variable in a General module.

Set that as an indicator of what should be done. Then use that indicator
variable in the userform_initialize procedure.

option explicit
Public OpenFormModify as boolean
Sub ShowMyForm()
if something is true then
openformmodify = true
else
openformmodify = false
end if
End sub

And behind the userform:

Option Explicit
Private Sub UserForm_Initialize()
if openformmodify = true then
'initialize the form with a record
else
'initialize the form to add
end if
End Sub

Ray wrote:

I've a userform that needs to be loaded in one of two scenarios ...

First, it may be used to MODIFY an existing entry ... so would be pre-
loaded using data passed from another userform.

Or, it could be used ADD a new entry ... so would be loaded with all
fields blank.

How do I tell the userform which way to load? I could test to see if
the other userform is loaded, but doing so would automatically load it
anyway, right?

Thoughts or ideas?

TIA,
Ray


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you make a userform open automatically when you open excel? Evan Excel Worksheet Functions 1 March 11th 10 02:24 AM
The error of my ways. Cerberus Excel Discussion (Misc queries) 5 February 19th 08 09:36 PM
256 ways to make hamburger Nonni Excel Worksheet Functions 2 October 20th 06 11:50 PM
Ways to activate a macro eddied Excel Discussion (Misc queries) 2 February 7th 05 07:00 AM


All times are GMT +1. The time now is 08:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"