Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Capture/Passing Commandbutton click

When you run the CommandButton1_Click procedure, the code passes a value of
1 to the form's .Button property (.Button = 1). The Button property reads
iButton as 1 and saves it as the form's variable miButton. Then in the
form's method (sub) StartMeUp, the code looks for the value of miButton so
it knows which branch to execute.

I did not use the UserForm_Initialize subroutine, because it runs as soon as
I execute "With FltPlan". However, what I need is to run ".Button = 1"
before initializing the form. Therefore, I use StartMeUp as a delayed
initialization, if you will.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"WLMPilot" wrote in message
...
I understand everyting except the first part -- "Private miButton As
Long".
I don't understand how the value of Button (within the Commandbutton
section)
gets passed to iButton. I am fairly new to VBA, though I have programming
experience in BASIC, COBOL. Until I understand VBA better, if I don't see
x
= y format, then I get lost.

I also don't understand why the first line of the initialization section
is
changed from what I know to me "normal", ie Private Sub
UserForm_Initialize().

I believe I understand the Public Property routine will make miButton
value
available to every sub routine in section.

Thanks for your help and any explanation to erase my confusion,
Les


"Jon Peltier" wrote:

I would add a private module level variable to the declarations section
of
the userform:

Private miButton As Long

and a public property to the userform:

Public Property Button(iButton As Long)
miButton = iButton
End Property

I would write a conditional initialization routine in the userform:

Public Sub StartMeUp()
If miButton = 1 Then
' blah blah
ElseIf miButton = 2 Then
' yada yada
Else
' something's not right
End If
End Sub

Then my two procedures loading the userform would look like this:

Private Sub CommandButton1_Click() 'ENTER FLIGHT PLAN
With FltPlan
.Button = 1
.StartMeUp
.Show
End With
End Sub

Private Sub CommandButton2_Click() 'ENTER FLIGHT PLAN
With FltPlan
.Button = 2
.StartMeUp
.Show
End With
End Sub


- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"WLMPilot" wrote in message
...
Currently I have two commandbuttons: 1 = Enter Flight Data 2 = Edit
Flight Data

Private Sub CommandButton1_Click() 'ENTER FLIGHT PLAN
FltPlan.Show
End Sub

You can see what button 1 does. Except for the number 1, the
procecdure
for
CommandButton2 would be a mirror image of above procedure. I want to
pass
the value of the commandbutton to the initialization procedure of the
userform. Therefore if "EDIT" is clicked the I can navigate around
parts
of
the initialization routine to a section that will initialize the
userform
a
different way than that for ENTER.

Tip: If I am going to edit the data, will will pull data in from the
spreadsheet in the initialization section for EDIT.

Les

"Jim Thomlinson" wrote:

You have lost me on exactly what you want the button to do. Is it
intended as
a toggle button that puts the form into edit mode or exactly what???
--
HTH...

Jim Thomlinson


"WLMPilot" wrote:

I have a userform that contains over 24 data elements (textboxes &
comboboxes) used to accept data and place in a spreadsheet. I want
to
use
the same userform to pull the data, that was originally entered,
back
into
the userform when a user clicks the commandbutton to EDIT data.

I need to know how to capture the value of the commandbutton as
being
TRUE
and passing it to the routine that initializes the userform so that
I
can
GOTO section that pulls this data in.

Thanks,
Les






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
capture listbox click Joanne New Users to Excel 13 July 7th 07 01:00 PM
Capture button name or row # during click? robotman Excel Programming 2 May 10th 07 12:52 AM
Can you capture worksheet double click event from an Add-In???? JGeniti Excel Programming 4 January 23rd 06 07:37 PM
Mouse Over Graph, Capture Information on Click(Double Click) Dean Hinson[_3_] Excel Programming 1 December 6th 04 04:49 AM
capture shift-double-click Rob Bovey Excel Programming 0 July 13th 03 09:56 AM


All times are GMT +1. The time now is 03:00 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"