Newbie could use some help
This form comes up with a run-time error after sending the data to the sheet
"Table" Sheet "Inventory" Has Letters in column A and Nubers in Column B and C.
SalesList Is the name of a combo box
txtOurCost and txtRetailPrice are Text boxes on the form
Run-time error after the data is sent to the page, says
Could Not set the value property. type Mismatch.
I hit debug and it goes to this line in the code
Me.txtOurCost = Application.VLookup(Me.SalesList, .Range("a:d"), 2, False)
Here is the code i am using in that Form
Option Explicit
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Table")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtDate.Value
ws.Cells(iRow, 2).Value = Me.SalesList.Value
ws.Cells(iRow, 3).Value = Me.txtOurCost.Value
ws.Cells(iRow, 4).Value = Me.txtRetailPrice.Value
ws.Cells(iRow, 5).Value = Me.txtAmountSold.Value
'clear the data
Me.txtDate.Value = ""
Me.SalesList.Value = ""
Me.txtOurCost.Value = ""
Me.txtRetailPrice.Value = ""
Me.txtAmountSold.Value = ""
Me.txtDate.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub SalesList_Change()
With Sheets("inventory")
Me.txtOurCost = Application.VLookup(Me.SalesList, .Range("a:d"), 2, False)
Me.txtRetailPrice = Application.VLookup(Me.SalesList, .Range("a:d"), 3, False)
End With
End Sub
Private Sub UserForm_Initialize()
Dim i As Long, r As Range
With Sheets("Inventory")
For Each r In .Range("a2", .Range("a65536").End(xlUp))
Me.SalesList.AddItem r.Value
Next
End With
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button!"
End If
End Sub
Any help would be great
Any help would be Great
Bookmarks