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

JohnPapa

Registered User.
Local time
Today, 20:50
Joined
Aug 15, 2010
Messages
954
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'
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:50
Joined
Oct 29, 2018
Messages
21,553
If I read that link properly, you may be missing a step. Try:
Code:
Me.imgLogo.PictureData = MyImage
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:50
Joined
Feb 19, 2002
Messages
43,512
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.
 

JohnPapa

Registered User.
Local time
Today, 20:50
Joined
Aug 15, 2010
Messages
954
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.
 

JohnPapa

Registered User.
Local time
Today, 20:50
Joined
Aug 15, 2010
Messages
954
Your suggestion

Code:
Me.imgLogo.PictureData = MyImage

works on a report as well, but does not print the image, when I print the report.
 

JohnPapa

Registered User.
Local time
Today, 20:50
Joined
Aug 15, 2010
Messages
954
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.
 

JohnPapa

Registered User.
Local time
Today, 20:50
Joined
Aug 15, 2010
Messages
954
On the no printing problem, if I convert to .pdf it prints ok.
 

Users who are viewing this thread

Top Bottom