Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm afraid I may have bitten of more than I can chew.....
I created a user form whereby a combo box is used to list all available records in column A on a workbook (listing starts from A3 to last record in column A), the appropriate part number in this case, is then selected from the combo box, the record adjacent to the part number selected (in Column B) is then looked at to see what type of product code the part number is. Then I want to initialize a user form for that product type and load it with data from the same row the part number came from, so the difficulty I'm experiencing currently is the macro first runs the Private Sub Userform_Initialize() seen below, it permits me to select a part number from the combo box. Then I press a command button to run the Private Sub CommandButton1_Click() macro, it fails on the Call rmMetalQuoteForm line, I get a compile error, invalid property. How can I initialze this form and then populate the text boxes. To populate the text boxes see the third sub routine listed below, would the listindex be still valid even though it was called from a different sub routine, or am I going in the wrong direction? If any one can help me out it would be greatly appreciated. -------------------------------------------------------------------------- this allows the user to select the part no. Private Sub Userform_Initialize() 'Get Part Number Form Dim SourceWB As Workbook Dim myRng As Range With Me.ComboBox1 .ColumnCount = 2 .ColumnWidths = "12;0" 'hide the second column .Clear Set SourceWB = Workbooks.Open("C:\MyFolder\MyWorkbook.xls", False, True) With SourceWB.Worksheets(1) Set myRng = .Range("A3:B" & .Cells(.Rows.Count, "A").End(xlUp).Row) End With .List = myRng.Value SourceWB.Close False End With End Sub ------------------------------------------------------------------------- this sub will re-direct the user to the appropriate user form depending upon the product code in the adjacent cell to the part number (same row but in column B) 'Option Explicit Dim myVar As Variant 'String/Long/double??? With Me.ComboBox1 If .ListIndex -1 Then myVar = .List(.ListIndex, 1) '<-- second column! MsgBox myVar 'for testing only Select Case LCase(myVar) Case Is = "Metal" Call frmMetalQuoteForm Case Is = "Glass" Call frmGlassQuoteForm End Select End If End With End Sub ----------------------------------------------------------------------------- this is one of the forms that requires loading with data Private Sub Userform_Initialize() 'Metals Quote Form myVar1 = .List(.ListIndex, 0) myVar2 = .List(.Listindex, 1) myVar3 = .List(.Listindex, 2) frmMetalQuoteForm.txtQuote.Value = myVar1 frmMetalQuoteForm.txtQuote.Value = myVar2 frmMetalQuoteForm.txtQuote.Value = myVar3 End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Populating a form | Excel Worksheet Functions | |||
Populating data to other worksheet via data validation | Excel Programming | |||
Populating a combobox within a form with concatenated data | Excel Programming | |||
populating a combo box on form inilialization | Excel Programming | |||
Populating worksheet with data from Access | Excel Programming |