ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
On my worksheet i have a table of customers with their values.
I have a useform of which the code is shown below.
My issue is TextBox4
I open the userform & enter a customers ID number & then the form is populated.
So in this example i enter 1 & i see the textboxes are populated.
I look at Textbox4 & i see £25.00
Lets say i now close the userform, on my worksheet i change the value of £25.00 to £20.00
Now i expect that when i open the userform & enter 1 again that Textbox4 should show £20.00 BUT i see 20
This pattern seems to be the same for any customer.
If i cgange the value on the worksheet then open the userform i only see example 35 as opposed £35.00 or 50 as oppose £50.00
Do you see wht the correct item isnt be displayed when userform is open.
I have a useform of which the code is shown below.
My issue is TextBox4
I open the userform & enter a customers ID number & then the form is populated.
So in this example i enter 1 & i see the textboxes are populated.
I look at Textbox4 & i see £25.00
Lets say i now close the userform, on my worksheet i change the value of £25.00 to £20.00
Now i expect that when i open the userform & enter 1 again that Textbox4 should show £20.00 BUT i see 20
This pattern seems to be the same for any customer.
If i cgange the value on the worksheet then open the userform i only see example 35 as opposed £35.00 or 50 as oppose £50.00
Do you see wht the correct item isnt be displayed when userform is open.
Rich (BB code):
Private Sub CustomerID_Change()
Dim id As Variant, rowcount As Long, foundcell As Range
Dim lRow As Long
Dim i As Long
On Error Resume Next
id = CLng(CustomerID.Value)
If Err.Number <> 0 Then
id = 0
End If
On Error GoTo 0
SpinButton1.Value = id
rowcount = Sheets("G INCOME").Cells(Rows.Count, 13).End(xlUp).Row ' THIS IS COLUMN NUMBER WHERE CUSTOMER ID IS LOCATED
With Worksheets("G INCOME").Range("M1:M" & rowcount) ' THIS IS CELL REFERENCE OF WHERE THE TEXT CUSTOMER ID IS LOCATED
Set foundcell = .Find(what:=id, LookIn:=xlValues)
If Not foundcell Is Nothing Then
lRow = foundcell.Row
For i = 1 To 5
Me.Controls("TextBox" & i).Value = .Cells(lRow, i + 1)
Next i
Else
For i = 1 To 5
Me.Controls("TextBox" & i).Value = vbNullString
Next i
End If
End With
End Sub