ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,731
- Office Version
- 2007
- Platform
- Windows
When i try to clear the values on my userform i see the following error message
Type Mismatch,i debug & see the line of code in yellow highlighted
The Textbox in question that gives me the issue is called CustomerID
This is how i clear & try to set focus in the textboxes.
Type Mismatch,i debug & see the line of code in yellow highlighted
The Textbox in question that gives me the issue is called CustomerID
Rich (BB code):
Dim id As Integer, rowcount As Integer, foundcell As Range
id = CustomerID.Value
rowcount = Sheets("G INCOME").Cells(Rows.Count, 13).End(xlUp).Row ' THIS IS COLUMN NUMBER WHERE EMP ID LOCATED
With Worksheets("G INCOME").Range("M1:M" & rowcount) ' THIS IS CELL REFERENCE OF WHERE THE TEXT EMP ID IS LOCATED
Set foundcell = .Find(what:=id, LookIn:=xlValues)
If Not foundcell Is Nothing Then
TextBox1.Value = .Cells(foundcell.Row, 2)
TextBox2.Value = .Cells(foundcell.Row, 3)
TextBox3.Value = .Cells(foundcell.Row, 4)
TextBox4.Value = .Cells(foundcell.Row, 5)
TextBox5.Value = .Cells(foundcell.Row, 6)
Else
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
End If
End With
End Sub
This is how i clear & try to set focus in the textboxes.
Rich (BB code):
Private Sub ClearValues_Click()
CustomerID = ""
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
CustomerID.SetFocus
End Sub