1. I have a picture control in my VB application.
2. I created a OLE object in Access that holds the picture.
3. I insert the picture in access and save it.
4. If I try to view and safe pictures in VB it don’t want to safe the picture or view it.
5. Can I maybe assign a Path to each photo that I want to view in the database without saving the actual photo.
6. Please help with the correct code to use.
Here is the coding I used :
______________________________________________________
General Declaration
Dim cn As ADODB.Connection 'Connect to a Database.
Public rs As ADODB.Recordset 'Set records.
_______________________________________________________
Private Sub Picture1_Click()
Dim strFileName As String 'String of file to open
Dim strText As String 'Contents of file
Dim strFilter As String 'Common Dialog filter string
Dim strBuffer As String 'String buffer variable
Dim FileHandle% 'Variable to hold file handle
'Set the Common Dialog filter
strFilter = "Graphics (*.BMP)|*.BMP|Graphics (*.JPG)|*.JPG|Graphics (*.TIF)|*.TIF|Graphics (*.WMF)|*.WMF|Graphics (*.GFX)|*.GFX|All Files (*.*)|*.*"
cdMain.Filter = strFilter
'Open the common dialog
cdMain.ShowOpen
'Make sure the retrieved filename is not a blank string
If cdMain.FileName <> "" Then
'If it is not blank open the file
strFileName = cdMain.FileName
'Get a free file handle and assign it to the file handle variable
FileHandle% = FreeFile
'Open the file
Open strFileName For Input As #FileHandle%
’Make the mouse cursor an hourglass
MousePointer = vbHourglass
'Traverse the lines of the file
Do While Not EOF(FileHandle%) ' Check for end of file.
'Read a line of the file
Line Input #FileHandle%, strBuffer ' Read line of data.
'Add the line from the output buffer to the text string
strText = strText & strBuffer & vbCrLf
Loop
'Change the mousepointer back to the arrow
MousePointer = vbDefault
'Close the file once you have had your way with it
Close #FileHandle%
End If
_______________________________________________________
Private Sub cmdSave_Click()
rs!Picture = Picture1.Picture & ""
________________________________________________________
Public Sub PopulateControls()
Picture1.Picture = rs!Photo & ""
_________________________________________________________