albertocarrillom
New Member
- Joined
- Apr 24, 2024
- Messages
- 5
- Office Version
- 365
I am new developing VBA programs. I am creating an Inventory of my job, sometimes the programs work perfectly fine, but some other the program does not work out.
It appears this message:
I am attaching my code, my problem is in the .RowSource = rg.Address:
Private Sub AddButton_Click()
Dim frm As New formStockDetailsNew
frm.Show
Call AddDataToListBox
End Sub
Private Sub ButtonRemove_Click()
Call RemoveRow
End Sub
Private Sub EditButton_Click()
Call EditRow
End Sub
Private Sub ExitButton_Click()
Unload Me
End Sub
Private Sub listboxStock_Click()
End Sub
Private Sub NewButton_Click()
Call NewRow
End Sub
Private Sub RemoveButton_Click()
Call DeleteRow(listboxStock.ListIndex)
End Sub
Private Sub UserForm_Initialize()
Call AddDataToListBox
Me.Width = 800
Me.Height = 340
End Sub
Private Sub AddDataToListBox()
'Get the Range
Dim rg As Range
Set rg = GetRange()
'Link the data to the ListBox
With listboxStock
.RowSource = rg.Address
.ColumnCount = rg.Columns.Count
.ColumnWidths = "100;160;80;60;60;80;90;110"
.ColumnHeads = True
.ListIndex = 0
End With
End Sub
Private Sub EditRow()
Dim frm As New formStockDetailsEdit
frm.CurrentRow = listboxStock.ListIndex
frm.Show vbModal
End Sub
Private Sub NewRow()
Dim frm As New AddQtyForm
frm.CurrentRow = listboxStock.ListIndex
frm.Show vbModal
End Sub
Private Sub RemoveRow()
Dim frm As New RemoveQtyForm
frm.CurrentRow = listboxStock.ListIndex
frm.Show vbModal
End Sub
The help will be really appreciated.
Cheers
It appears this message:
I am attaching my code, my problem is in the .RowSource = rg.Address:
Private Sub AddButton_Click()
Dim frm As New formStockDetailsNew
frm.Show
Call AddDataToListBox
End Sub
Private Sub ButtonRemove_Click()
Call RemoveRow
End Sub
Private Sub EditButton_Click()
Call EditRow
End Sub
Private Sub ExitButton_Click()
Unload Me
End Sub
Private Sub listboxStock_Click()
End Sub
Private Sub NewButton_Click()
Call NewRow
End Sub
Private Sub RemoveButton_Click()
Call DeleteRow(listboxStock.ListIndex)
End Sub
Private Sub UserForm_Initialize()
Call AddDataToListBox
Me.Width = 800
Me.Height = 340
End Sub
Private Sub AddDataToListBox()
'Get the Range
Dim rg As Range
Set rg = GetRange()
'Link the data to the ListBox
With listboxStock
.RowSource = rg.Address
.ColumnCount = rg.Columns.Count
.ColumnWidths = "100;160;80;60;60;80;90;110"
.ColumnHeads = True
.ListIndex = 0
End With
End Sub
Private Sub EditRow()
Dim frm As New formStockDetailsEdit
frm.CurrentRow = listboxStock.ListIndex
frm.Show vbModal
End Sub
Private Sub NewRow()
Dim frm As New AddQtyForm
frm.CurrentRow = listboxStock.ListIndex
frm.Show vbModal
End Sub
Private Sub RemoveRow()
Dim frm As New RemoveQtyForm
frm.CurrentRow = listboxStock.ListIndex
frm.Show vbModal
End Sub
The help will be really appreciated.
Cheers