How to get jpg file into userform using multiple criterias thru Search Command Button

Vivek Roshan

New Member
Joined
Feb 15, 2018
Messages
24
Hello friends,

I
have created a userform which has search button set with criteria SUBJECT in column A which is working perfectly ok. I added 'INSERT IMAGE' command button to create jpg file with "incoming letter reference no." which is column D. It is nicely creating a jpg file with INCOMING LETTER REFERENCE NO. in a separate folder called ' photos'. Name of the Jpg file and letter reference no. are same. I want that picture to be displayed in userform with search record. INCOMING LETTER REFERENCE NO.' is in (Column 4 (D1). It seems that I have to use multiple criterias which I am not able to do.

Can anybody please help me. Will be much appreciated.

Thanks a lot in advance.
Vivek
=======================================================

'Here is the code for search command which is working well, but code for displaying jpg file is not added.

Private Sub CmdSearch_Click()

If Me.ComboBox1.Value <> "" Then
Dim Findvalue As Range
Set Findvalue = Sheet2.Range("A:A").Find(What:=Me.ComboBox1.Value, LookIn:=xlFormulas, LookAt:=xlWhole)


If WorksheetFunction.CountIf(Sheets("ICC_Data").Range("A:A"), Me.ComboBox1.Text) > 0 Then

Me.TextBox5.Value = Findvalue.Value
Me.TextBox1.Value = Findvalue.Offset(0, 1).Value
Me.TextBox2.Value = Findvalue.Offset(0, 2).Value
Me.TextBox3.Value = Findvalue.Offset(0, 3).Value
Me.TextBox4.Value = Findvalue.Offset(0, 4).Value
Me.TextBox6.Value = Findvalue.Offset(0, 5).Value
Me.ListBox1.Value = Findvalue.Offset(0, 6).Value
Me.ListBox2.Value = Findvalue.Offset(0, 7).Value

If Findvalue.Offset(0, 8).Value = "YES" Then
Me.OptionButton1.Value = True
End If

If Findvalue.Offset(0, 8).Value = "NO" Then
Me.OptionButton2.Value = True
End If

If Findvalue.Offset(0, 8).Value = "PENDING" Then
Me.OptionButton3.Value = True
End If

Me.TextBox7.Value = Findvalue.Offset(0, 9).Value
Me.TextBox8.Value = Findvalue.Offset(0, 10).Value
CmdAdd.Enabled = False
Else

MsgBox "Data not found"
End If
Else
MsgBox "Please choose any data first "
End If

End Sub

==================================================
'The code for INSERT IMAGE which is working well is given below:

Private Sub CommandButton1_Click()
Dim image_path As Variant
Dim var As String
image_path = Application.GetOpenFilename(FileFilter:="Picture Files (Files image),*.gif;*.jpg;*.jpeg;*.bmp", Title:="INSERT IMAGE")
If image_path <> False Then
Me.Image1.Picture = LoadPicture(image_path)

Me.Image1.Visible = True
End If
var = TextBox3.Text

SavePicture Image1.Picture, ThisWorkbook.Path & "\photos" & var & ".jpg"
End sub
 
Last edited:

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top