dorsetcream
New Member
- Joined
- Feb 19, 2019
- Messages
- 1
Hi all,
My database has multiple columns as follows
Column A: Tracking number (txttracking)
Column B: New / Resupply (txtrequest)
Column C: Resupply No. (txtresupplyno)
etc
e.g. I have 3 rows with the same tracking number
ABC123 new n/a
ABC123 resupply 1
ABC123 resupply 2
Now I have a list and I would like to create a userform with search function (search by tracking number). I was able to do the search function but it only show up the first entry with the matching criteria (i.e. only show ABC123 new, but not resupply 1 and 2).
I'm a new guy here so it would be great if someone can show me a code for the 'find next' button so that when i press 'Search' button the form will show ABC123 new, then click 'find next' to show ABC123 resupply 1, then click 'find next' again to show ABC123 resupply 2?
My current code for search button is as below:
Thanks a lot!
My database has multiple columns as follows
Column A: Tracking number (txttracking)
Column B: New / Resupply (txtrequest)
Column C: Resupply No. (txtresupplyno)
etc
e.g. I have 3 rows with the same tracking number
ABC123 new n/a
ABC123 resupply 1
ABC123 resupply 2
Now I have a list and I would like to create a userform with search function (search by tracking number). I was able to do the search function but it only show up the first entry with the matching criteria (i.e. only show ABC123 new, but not resupply 1 and 2).
I'm a new guy here so it would be great if someone can show me a code for the 'find next' button so that when i press 'Search' button the form will show ABC123 new, then click 'find next' to show ABC123 resupply 1, then click 'find next' again to show ABC123 resupply 2?
My current code for search button is as below:
Code:
Private Sub search_Click()
'Transferring values from the search box to the controls
Dim FindRow
Dim i As Integer
Dim cRow As String
Set FindRow = nwb.Sheets("Master Database").Range("A:A").Find(What:=cRow, LookIn:=xlValues)
Me.txtCurrentAddress = FindRow.Address
Me.txtCurrentAddress.Visible = False
'error block
On Error GoTo errHandler:
'find the row with the data
cRow = txttracking.Text
If txttracking.Text <> "" Then
Set FindRow = nwb.Sheets("Master Database").Range("A:A").Find(What:=cRow, LookIn:=xlValues)
'add the values to the userform
txttracking.Text = FindRow
txtrequest.Text = FindRow.Offset(0, 1)
txtresupplyno.Text = FindRow.Offset(0, 2)
End If
'error block
On Error GoTo 0
Exit Sub
errHandler:
MsgBox "Record Not Found. "
End Sub
Thanks a lot!