Dear all, I have been headache for this 2 functions for many days already. I hope someone can help me to solve my problem.
I have a search button which allow me to search record by using product_id, and display the picture. Then, i wish to move next / previous start from the searched record. I have tried many codes but not work. all move start from first record. ???
So far the search and show picture work good for me... but i dunno how to write the code for move next / previous....
the search code i get from online, i tried can use then i just use it. if you want to help me to modify also can, i will really appreciate that.
Additional to that: in my showPic() function, if no picture found, i want to display a default picture, how should i do it?
I have a search button which allow me to search record by using product_id, and display the picture. Then, i wish to move next / previous start from the searched record. I have tried many codes but not work. all move start from first record. ???
So far the search and show picture work good for me... but i dunno how to write the code for move next / previous....
the search code i get from online, i tried can use then i just use it. if you want to help me to modify also can, i will really appreciate that.
Additional to that: in my showPic() function, if no picture found, i want to display a default picture, how should i do it?
Rich (BB code):
Private Sub cmdSearch_Click()
Dim rngID As Range
Set rngID = Sheets("Main").Range("B:B").Find(txtID, , xlValues, xlWhole, 1, 1, 0)
If Not rngID Is Nothing Then
txtCategory.Text = rngID.Offset(0, -1).Value
txtName.Text = rngID.Offset(0, 1).Value
txtStock.Text = rngID.Offset(0, 2).Value
txtPrice.Text = rngID.Offset(0, 3).Value
txtType1.Text = rngID.Offset(0, 4).Value
txtType2.Text = rngID.Offset(0, 5).Value
txtID.Tag = rngID.Address 'store the location of the matched ProductID
Call showPic
Else
MsgBox StrConv(txtID.Text, vbUpperCase), vbExclamation, "No Match Found"
End If
End Sub
Private Sub showPic()
Dim **** As String
**** = ThisWorkbook.Path & "\" & "AP_Folder" & "\" & txtID.Value & ".jpg"
If Dir(****) <> "" Then
Image1.Picture = LoadPicture(****)
Else
Image1.Picture = LoadPicture(none)
End If
End Sub