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
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: