Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default userform problems

Hi all,

I open a sheet that shows the number of items in stock and their value for
each item. When I buy or sell another item (even something new that doesn't
exists in stock) I need to update my inventory. I made 2 userforms to
collect info buy/sell and use the info to do that but no luck :(

Form1 is for sold items with a txt box where you can only choose what's in
the inventory and not add any item, an OK and clear button.
Form2 for buying, adding to the inventory where you see a list and can add
to it.

Userforms don't load and I get errors ... "userform empty ",etc.
Have lost days on this problem ... ok sorry I'm dumb:)

PLS need to know:
1) the correct way for dynamicly (?) populating the combobox and the
textlist from a table in a worksheet and retrieving the values selected or
added to the forms.
2) How do I load, show, and close the 2 populated forms.

Any help appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default userform problems

Hi Oboy, First we'll address your second question,
to show userforms use the .show method like this

Private Sub Workbook_Open()
'Insert your form names after Call statment
Call FrmSoldItems.Show(vbModeless)
Call FrmDummy.Show(vbModeless)
End Sub

This will show both form at the same time and allow you to swtich between
them.

On to your first queston. There is about a a handfull of ways to Fill a
combobox/Listbox control. Here is my solution,

Private Sub UserForm_Initialize()
'Your combobox Name
With cboSoldItems
'if no columnheads change to false
.ColumnHeads = True

'Show Item & Qty
.ColumnCount = 2

'Adjust to fit your values
.ColumnWidths = 50

'Pass the Worksheet to "GetRowSource" to add
'values to your comboBox
.RowSource = GetRowSource(Worksheets("Sheet1"))
End With

' Example for listbox
With lboInventory
.ColumnHeads = True
.ColumnCount = 2
.ColumnWidths = 50
.RowSource = GetRowSource(Worksheets(1))
End With

End Sub

Public Function GetRowSource(ByVal ws As Worksheet) As String
Dim LastRow As Long

'Finds last row from bottom up in column 1("A")
LastRow = ws.Cells(Rows.Count, 1).End(xlUp).Row

'assumes first two columns contain you values,
'and first row contains columnheads
GetRowSource = ws.Range("A2", "B" & LastRow).Address
End Function


"Oboy" wrote:

Hi all,

I open a sheet that shows the number of items in stock and their value for
each item. When I buy or sell another item (even something new that doesn't
exists in stock) I need to update my inventory. I made 2 userforms to
collect info buy/sell and use the info to do that but no luck :(

Form1 is for sold items with a txt box where you can only choose what's in
the inventory and not add any item, an OK and clear button.
Form2 for buying, adding to the inventory where you see a list and can add
to it.

Userforms don't load and I get errors ... "userform empty ",etc.
Have lost days on this problem ... ok sorry I'm dumb:)

PLS need to know:
1) the correct way for dynamicly (?) populating the combobox and the
textlist from a table in a worksheet and retrieving the values selected or
added to the forms.
2) How do I load, show, and close the 2 populated forms.

Any help appreciated.

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
problems with a userform David Hepner Excel Programming 0 September 7th 05 01:14 AM
userform problems [email protected] Excel Programming 0 March 7th 05 08:56 PM
userform problems [email protected] Excel Programming 0 February 16th 05 06:10 PM
userform problems [email protected] Excel Programming 0 February 13th 05 01:27 PM
UserForm Problems Joe[_27_] Excel Programming 2 October 21st 03 12:52 PM


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