Access FE - SQL Server BE insert/display image (1 Viewer)

JohnPapa

Registered User.
Local time
Today, 17:41
Joined
Aug 15, 2010
Messages
1,037
I use Access as my FE and SQl Server as my BE.

I want to be able to insert an image into the SQl Server BE from my Access FE and be able to display this image.

I looked at the following link

Insert a picture into a Access table with a SQL Server Backend - Stack Overflow

but it gets stuck at

Code:
Me!imgLogo = MyImage

when running

Code:
' save current record
     If Me.Dirty Then Me.Dirty = False
    
     Dim MyImage() As Byte
    
     MyImage = GetFileBytes(Me.txtLogo)
    
     Me!imgLogo = MyImage
     Me.Dirty = False

The error is "Run-time error '438' Object doesn't support this property or method'
 
If I read that link properly, you may be missing a step. Try:
Code:
Me.imgLogo.PictureData = MyImage
 
Why would you save a dirty record and then immediately dirty it again and then immediately force it to save again. Access always takes care of saving dirty records. The only time you have to do this manually is if you know the record needs to be saved and you also know that your action is not going to cause Access to save it. For example, if the user dirties a record and then presses a button to open a report. The change would not appear on the report unless you force the record to be saved before you open the report. Same if your button is opening a different form. You always save the current record prior to running code that opens a different object.
 
If I read that link properly, you may be missing a step. Try:
Code:
Me.imgLogo.PictureData = MyImage
With your suggestion the image appears on the form, but it does not get saved in the SQL Server DB, so that I can display it from the SQL Server Db.
 
Your suggestion

Code:
Me.imgLogo.PictureData = MyImage

works on a report as well, but does not print the image, when I print the report.
 
To store I may have to use GetChunk and AppendChunk.

To invoke from SQL Server I need to copy file to local folder and read file.

I just need to figure out how to do this.
 
On the no printing problem, if I convert to .pdf it prints ok.
 

Users who are viewing this thread

Back
Top Bottom