How to save an image with MS Access ?
How to save an image with MS Access ?
This is the code that I use on a save button in an acces form with the active x. I want to save the picture after a modification:
Private Sub SaveImage_Click()
Dim sImageString As String
Dim strLinkedDoc
strLinkedDoc = Me.Linked_Doc
MsgBox strLinkedDoc
Select Case right(Me.Linked_Doc, 3)
Case "gif"
sImageString = oGdPicture.SaveAsString("gif")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsGif (strLinkedDoc)
Case "bmp"
sImageString = oGdPicture.SaveAsString("bmp")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsBmp (strLinkedDoc)
Case "jpg"
MsgBox "jpg"
sImageString = oGdPicture.SaveAsString("jpg")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsJpeg (strLinkedDoc)
Case "peg"
sImageString = oGdPicture.SaveAsString("jpg")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsJpeg (strLinkedDoc)
Case "tif"
sImageString = oGdPicture.SaveAsString("tif")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsTiff (strLinkedDoc)
Case "wmf"
sImageString = oGdPicture.SaveAsString("jpg")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsJpeg (strLinkedDoc)
MsgBox "Converti en Jpeg"
Case Else
MsgBox "Format d'image invalide"
OgdViewer.ClosePicture
End Select
End Sub
Would you tell me why it doesn’t work? Also why Is it telling me that I use a not registered version when on the load event of my form I have enter the proper serial number
Private Sub SaveImage_Click()
Dim sImageString As String
Dim strLinkedDoc
strLinkedDoc = Me.Linked_Doc
MsgBox strLinkedDoc
Select Case right(Me.Linked_Doc, 3)
Case "gif"
sImageString = oGdPicture.SaveAsString("gif")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsGif (strLinkedDoc)
Case "bmp"
sImageString = oGdPicture.SaveAsString("bmp")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsBmp (strLinkedDoc)
Case "jpg"
MsgBox "jpg"
sImageString = oGdPicture.SaveAsString("jpg")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsJpeg (strLinkedDoc)
Case "peg"
sImageString = oGdPicture.SaveAsString("jpg")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsJpeg (strLinkedDoc)
Case "tif"
sImageString = oGdPicture.SaveAsString("tif")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsTiff (strLinkedDoc)
Case "wmf"
sImageString = oGdPicture.SaveAsString("jpg")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsJpeg (strLinkedDoc)
MsgBox "Converti en Jpeg"
Case Else
MsgBox "Format d'image invalide"
OgdViewer.ClosePicture
End Select
End Sub
Would you tell me why it doesn’t work? Also why Is it telling me that I use a not registered version when on the load event of my form I have enter the proper serial number
I need more precisions.Would you tell me why it doesn’t work?
1 - What you want exactly to do ?
2 - What is the return code of each methods you are using:
I suggest you to replace this kind of code:
Code: Select all
Case "gif"
sImageString = oGdPicture.SaveAsString("gif")
oGdPicture.CloseImage (OgdViewer.GetNativeImage())
oGdPicture.LoadFromString (sImageString)
oGdPicture.SaveAsGif (strLinkedDoc)
By this one:
Code: Select all
Dim nState as long
Case "gif"
sImageString = oGdPicture.SaveAsString("gif")
nState = oGdPicture.GetState()
If nState = 0 Then
OgdViewer.ClosePicture
nStat = oGdPicture.LoadFromString (sImageString)
If nState = 0 Then
nState = oGdPicture.SaveAsGif (strLinkedDoc)
If nState <> 0 then
Msgbox "Can't Save as GIF, error code no: " & Str(nState)
End if
Else
Msgbox "Can't load from string, error code no: " & Str(nState)
End If
Else
Msgbox "Can't save as string, error code no: " & Str(nState)
End if
Also why Is it telling me that I use a not registered version when on the load event of my form I have enter the proper serial number
What is the code you are using to unlock the component ? (Please replace your license key by XXX)
Loïc
Save as problem in access
I have several button on a form that does different thing like rotate, greyscale... I am not able to save my modification after a change. I tried your code but I had to change getstate for getstat and remove the bracket after the getstate. I get error code 1 on saveasstring
OK I think your problem come from the code you are using before calling the SaveImage_Click() button.
You have to check that the oGdPicture object have a good native image.
You can do it like that into your SaveImage_Click() method
You have to check that the oGdPicture object have a good native image.
You can do it like that into your SaveImage_Click() method
Code: Select all
Private Sub SaveImage_Click()
If oGdPicture.SaveAsJpeg("c:\removeme.jpg") = 0 Then
msgbox "OK"
Else
MsgBox "Error: " & str(oGdPicture.GetStat)
End If
Like that:
Loïc
Code: Select all
Dim oGdPicture2 As New GdpicturePro.cGdPicture
oGdPicture.SetNativeImage(GdViewer.GetNativeImage)
oGdPicture.SaveAsJpeg("c:\removeme.jpg")
Set oGdPicture2 = Nothing
Loïc
Who is online
Users browsing this forum: Amazon [Bot] and 2 guests