Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA: Pass value when clicking button

I have a problem with a Procedure Declaration to capture a value in
variable when clicking a button in a Dialog Box. I’m pretty fluent i
VBA as such but I’ve hardly ever worked with Dialog Boxes.
I’m trying to pass the value of blnSwitch when clicking Commandbutton_
to Sub Status() and further to BaseRoutine().
Does anybody have a solution?

Milli

Sub BaseRoutine()
----
Call Status(blnSwitch)

Select Case blnSwitch

Case = ”1”

Do something 1

Case = ”2”

Do something 2

End Select

End Sub

Sub Status(blnSwitch as Boolean)
----
Call ShowForm(I guess this is where blnSwitch should be passed)

End Sub

Sub ShowForm()

MissingAnswersForm.Show

End Sub

Private Sub MissingAnswersForm_Initialize(vntReturnCriteria A
Variant)

Call BaseRoutine

End Sub

Private Sub CommandButton1_Click()

Unload Me
blnSwitch = ”1”

End Sub

Private Sub CommandButton2_Click()

Unload Me

End Su

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel VBA: Pass value when clicking button

Make blnSwitch a public variable at the top of a general module. (remove
anywhere else it might be declared)

Then it will be visible to all the modules in the project.

--
Regards,
Tom Ogilvy

"Milli " wrote in message
...
I have a problem with a Procedure Declaration to capture a value in a
variable when clicking a button in a Dialog Box. I'm pretty fluent in
VBA as such but I've hardly ever worked with Dialog Boxes.
I'm trying to pass the value of blnSwitch when clicking Commandbutton_1
to Sub Status() and further to BaseRoutine().
Does anybody have a solution?

Milli

Sub BaseRoutine()
----
Call Status(blnSwitch)

Select Case blnSwitch

Case = "1"

Do something 1

Case = "2"

Do something 2

End Select

End Sub

Sub Status(blnSwitch as Boolean)
----
Call ShowForm(I guess this is where blnSwitch should be passed)

End Sub

Sub ShowForm()

MissingAnswersForm.Show

End Sub

Private Sub MissingAnswersForm_Initialize(vntReturnCriteria As
Variant)

Call BaseRoutine

End Sub

Private Sub CommandButton1_Click()

Unload Me
blnSwitch = "1"

End Sub

Private Sub CommandButton2_Click()

Unload Me

End Sub


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA: Pass value when clicking button

That works perfect. Thanks.

Are there alternative routes?

Regards
Milli

Tom Ogilvy wrote:
*Make blnSwitch a public variable at the top of a general module.
(remove
anywhere else it might be declared)

Then it will be visible to all the modules in the project.

--
Regards,
Tom Ogilvy

"Milli " wrote in message
...
I have a problem with a Procedure Declaration to capture a value i

a
variable when clicking a button in a Dialog Box. I'm pretty fluen

in
VBA as such but I've hardly ever worked with Dialog Boxes.
I'm trying to pass the value of blnSwitch when clickin

Commandbutton_1
to Sub Status() and further to BaseRoutine().
Does anybody have a solution?

Milli

Sub BaseRoutine()
----
Call Status(blnSwitch)

Select Case blnSwitch

Case = "1"

Do something 1

Case = "2"

Do something 2

End Select

End Sub

Sub Status(blnSwitch as Boolean)
----
Call ShowForm(I guess this is where blnSwitch should be passed)

End Sub

Sub ShowForm()

MissingAnswersForm.Show

End Sub

Private Sub MissingAnswersForm_Initialize(vntReturnCriteria As
Variant)

Call BaseRoutine

End Sub

Private Sub CommandButton1_Click()

Unload Me
blnSwitch = "1"

End Sub

Private Sub CommandButton2_Click()

Unload Me

End Sub


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


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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel VBA: Pass value when clicking button

You could declare blnSwitch as a public variable in the Userform module then

Userform1.Load ' not required - as soon as you reference it
' if it doesn't exist, it is loaded.
userform1.blnSwitch = True
Userform1.Show


--
Regards,
Tom Ogilvy


"Milli " wrote in message
...
That works perfect. Thanks.

Are there alternative routes?

Regards
Milli

Tom Ogilvy wrote:
*Make blnSwitch a public variable at the top of a general module.
(remove
anywhere else it might be declared)

Then it will be visible to all the modules in the project.

--
Regards,
Tom Ogilvy

"Milli " wrote in message
...
I have a problem with a Procedure Declaration to capture a value in

a
variable when clicking a button in a Dialog Box. I'm pretty fluent

in
VBA as such but I've hardly ever worked with Dialog Boxes.
I'm trying to pass the value of blnSwitch when clicking

Commandbutton_1
to Sub Status() and further to BaseRoutine().
Does anybody have a solution?

Milli

Sub BaseRoutine()
----
Call Status(blnSwitch)

Select Case blnSwitch

Case = "1"

Do something 1

Case = "2"

Do something 2

End Select

End Sub

Sub Status(blnSwitch as Boolean)
----
Call ShowForm(I guess this is where blnSwitch should be passed)

End Sub

Sub ShowForm()

MissingAnswersForm.Show

End Sub

Private Sub MissingAnswersForm_Initialize(vntReturnCriteria As
Variant)

Call BaseRoutine

End Sub

Private Sub CommandButton1_Click()

Unload Me
blnSwitch = "1"

End Sub

Private Sub CommandButton2_Click()

Unload Me

End Sub


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



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



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
Global Address List after clicking E-mail button in Excel 2003 elance Excel Discussion (Misc queries) 0 October 8th 09 02:34 PM
clicking on a button copies the choice *(VBA) Thrava Excel Discussion (Misc queries) 1 October 2nd 06 10:42 PM
Clicking on restore window button changing the freeze pane in exce SRIRAM Excel Discussion (Misc queries) 0 June 27th 05 10:29 AM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
Selecting a random number from a set criteria by clicking a button Caitlin[_2_] Excel Programming 1 November 6th 03 12:12 PM


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

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

About Us

"It's about Microsoft Excel"