LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Populating form with data from worksheet

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
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
Populating a form Deborah Excel Worksheet Functions 2 January 30th 09 05:34 PM
Populating data to other worksheet via data validation kuansheng Excel Programming 2 February 16th 06 08:18 AM
Populating a combobox within a form with concatenated data [email protected] Excel Programming 2 February 8th 06 03:07 AM
populating a combo box on form inilialization JulieD Excel Programming 1 September 7th 04 11:23 AM
Populating worksheet with data from Access EManning Excel Programming 0 August 3rd 04 09:33 PM


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