#1   Report Post  
Posted to microsoft.public.excel.misc
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Control Access

Thanks in advance

Sheet1 has several controls from control toolbox.
Sheet2 has a command button (name: Update record) with 'Click' event.

Question, please
In the 'Click' event in sheet2, I want to access the values of contols in
sheet1.


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,510
Default Control Access

Hi Jay,

Not sure if you just want the code for one individual control at a time or
if you want to cycle through all controls so here's both.

Private Sub CommandButton1_Click()
'Individual control
Dim myVariable As Variant

myVariable = Sheets("Sheet1").ComboBox1.Value

MsgBox myVariable


End Sub

Private Sub CommandButton2_Click()

Dim objCtrl As Object
Dim strCtrlname As String
Dim ctrlValue As Variant 'Variant for all data types

With Sheets("Sheet1")
For Each objCtrl In .OLEObjects
strCtrlname = objCtrl.Name
ctrlValue = objCtrl.Object.Value
MsgBox strCtrlname & " " & ctrlValue
Next objCtrl
End With

End Sub



--
Regards,

OssieMac


"Jay" wrote:

Thanks in advance

Sheet1 has several controls from control toolbox.
Sheet2 has a command button (name: Update record) with 'Click' event.

Question, please
In the 'Click' event in sheet2, I want to access the values of contols in
sheet1.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,510
Default Control Access

Change Dim statement
Dim objCtrl As OLEObject
in lieu of Dim objCtrl As Object
--
Regards,

OssieMac


"OssieMac" wrote:

Hi Jay,

Not sure if you just want the code for one individual control at a time or
if you want to cycle through all controls so here's both.

Private Sub CommandButton1_Click()
'Individual control
Dim myVariable As Variant

myVariable = Sheets("Sheet1").ComboBox1.Value

MsgBox myVariable


End Sub

Private Sub CommandButton2_Click()

Dim objCtrl As Object
Dim strCtrlname As String
Dim ctrlValue As Variant 'Variant for all data types

With Sheets("Sheet1")
For Each objCtrl In .OLEObjects
strCtrlname = objCtrl.Name
ctrlValue = objCtrl.Object.Value
MsgBox strCtrlname & " " & ctrlValue
Next objCtrl
End With

End Sub



--
Regards,

OssieMac


"Jay" wrote:

Thanks in advance

Sheet1 has several controls from control toolbox.
Sheet2 has a command button (name: Update record) with 'Click' event.

Question, please
In the 'Click' event in sheet2, I want to access the values of contols in
sheet1.


  #4   Report Post  
Posted to microsoft.public.excel.misc
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Control Access

Thank you, OssieMac

Jae

"OssieMac" wrote:

Change Dim statement
Dim objCtrl As OLEObject
in lieu of Dim objCtrl As Object
--
Regards,

OssieMac


"OssieMac" wrote:

Hi Jay,

Not sure if you just want the code for one individual control at a time or
if you want to cycle through all controls so here's both.

Private Sub CommandButton1_Click()
'Individual control
Dim myVariable As Variant

myVariable = Sheets("Sheet1").ComboBox1.Value

MsgBox myVariable


End Sub

Private Sub CommandButton2_Click()

Dim objCtrl As Object
Dim strCtrlname As String
Dim ctrlValue As Variant 'Variant for all data types

With Sheets("Sheet1")
For Each objCtrl In .OLEObjects
strCtrlname = objCtrl.Name
ctrlValue = objCtrl.Object.Value
MsgBox strCtrlname & " " & ctrlValue
Next objCtrl
End With

End Sub



--
Regards,

OssieMac


"Jay" wrote:

Thanks in advance

Sheet1 has several controls from control toolbox.
Sheet2 has a command button (name: Update record) with 'Click' event.

Question, please
In the 'Click' event in sheet2, I want to access the values of contols in
sheet1.


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
Excel spin box - no Control tab in Format Control dialong box tocoau Excel Worksheet Functions 7 August 10th 08 03:15 PM
Difference between a Forms Control verus Active-X Control funGT350 Excel Discussion (Misc queries) 6 May 6th 08 11:20 PM
Configuring Excel 2003 to control access to Trusted Publishers [email protected] Excel Discussion (Misc queries) 0 July 10th 06 09:04 AM
In EXCEL,How do you control the access to SHEET2, based on a value Vikranth Excel Worksheet Functions 0 March 16th 05 12:13 PM
Control Tab from Combo box- format control missing!! Mo Excel Discussion (Misc queries) 3 January 7th 05 01:09 PM


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