Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default transfer the name of combobox to module

I am trying to transfer the name of a combobox to my sub procedure.
Here is what I have so far. Obviously this keeps passing the name of
the combobox in quotations. If someone could let me know what I'm
doing wrong it would make my life alot easier.

Private Sub Line1Type1_DropButtonClick()
Dim strlinenum1 As Variant


Dim strlinenum2 As String



strlinenum1 = line1type1.Name
strlinenum2 = line1type2

L1T1 strlinenum1


End Sub


Sub L1T1(strlinenum1 As Variant)

Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strsql As String
Dim strcb2 As String


strsql = "SELECT DISTINCT 'Electrical', 'none' from materials"

cnn.Open strcnn
rst.Open strsql, cnn, adOpenStatic
rst.MoveFirst

ActiveSheet.strlinenum1.List = Application.Transpose(rst.GetRows)

ActiveSheet.strlinenum1.Clear
ActiveSheet.line1type2.Clear
ActiveSheet.Cells(87, 17).Value = 0

rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default transfer the name of combobox to module

On Jun 19, 12:44*pm, Shane Wierenga wrote:
I am trying to transfer the name of a combobox to my sub procedure.
Here is what I have so far. Obviously this keeps passing the name of
the combobox in quotations. *If someone could let me know what I'm
doing wrong it would make my life alot easier.

Private Sub Line1Type1_DropButtonClick()
* * Dim strlinenum1 As Variant

* * Dim strlinenum2 As String

* * strlinenum1 = line1type1.Name
* * strlinenum2 = line1type2

* *L1T1 strlinenum1

End Sub

Sub L1T1(strlinenum1 As Variant)

* * Dim cnn As New ADODB.Connection
* * Dim rst As New ADODB.Recordset
* * Dim strsql As String
* * Dim strcb2 As String

* * strsql = "SELECT DISTINCT 'Electrical', 'none' from materials"

* * cnn.Open strcnn
* * rst.Open strsql, cnn, adOpenStatic
* * rst.MoveFirst

* *ActiveSheet.strlinenum1.List = Application.Transpose(rst.GetRows)

* * ActiveSheet.strlinenum1.Clear
* * ActiveSheet.line1type2.Clear
* * ActiveSheet.Cells(87, 17).Value = 0

* * rst.Close
* * cnn.Close
* * Set rst = Nothing
* * Set cnn = Nothing

End Sub


I think methods and properties require that variables be explicitly
typed. Variants won't work. Try declaring strlinenum1 as String as
see what happens.

SteveM
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default transfer the name of combobox to module

Steve,
I tried that and end up getting the same thing "line1type1". Thanks
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default transfer the name of combobox to module

Pass the object itself (combobox), not the object.Name (string)

Private Sub Line1Type1_DropButtonClick()
'...
L1T1 Line1Type1
'...
End Sub


Sub L1T1(strlinenum1 As MSForms.Combobox) ' Or As Variant
'...
End Sub


--
Tim Zych
www.higherdata.com
Compare data in worksheets and find differences with Workbook Compare
A free, powerful, flexible Excel utility


"Shane Wierenga" wrote in message
...
I am trying to transfer the name of a combobox to my sub procedure.
Here is what I have so far. Obviously this keeps passing the name of
the combobox in quotations. If someone could let me know what I'm
doing wrong it would make my life alot easier.

Private Sub Line1Type1_DropButtonClick()
Dim strlinenum1 As Variant


Dim strlinenum2 As String



strlinenum1 = line1type1.Name
strlinenum2 = line1type2

L1T1 strlinenum1


End Sub


Sub L1T1(strlinenum1 As Variant)

Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strsql As String
Dim strcb2 As String


strsql = "SELECT DISTINCT 'Electrical', 'none' from materials"

cnn.Open strcnn
rst.Open strsql, cnn, adOpenStatic
rst.MoveFirst

ActiveSheet.strlinenum1.List = Application.Transpose(rst.GetRows)

ActiveSheet.strlinenum1.Clear
ActiveSheet.line1type2.Clear
ActiveSheet.Cells(87, 17).Value = 0

rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing


End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default transfer the name of combobox to module

I have tried that also. When I do that it appears as though it is
just passing the value of the combobox and not the combobox itself.
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
Compile Error in Hidden Module: Module 1 Mim Excel Programming 3 January 23rd 10 12:22 AM
Transfer Variable from Form to Module Gleam Excel Programming 2 September 6th 07 05:54 AM
code in module A to not execute a Worksheet_SelectionChange sub of another module Jack Sons Excel Discussion (Misc queries) 4 December 11th 05 11:52 PM
Transfer control to new module in macro BrianG[_4_] Excel Programming 2 October 20th 03 09:50 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 06:55 AM.

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"