Can you look for an image/OLE Object using dlookup

  • Thread starter ceebaby via AccessMonster.com
  • Start date
C

ceebaby via AccessMonster.com

Hi Folks

Is it possible to use dlookup to search and return an image?

I have tried the following but I keep getting an error message 91
Object variable or With block variable not set (Error 91). Here is what I
have tried:

Private Sub Text0_Click()

Dim test As Image

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = [Chk] ")
Me.Picture = test

End Sub

I am not sure what I have done in error. Any thoughts anyone?

Thanks in advance

--
Ceebaby

Trying to be great at Access

Message posted via AccessMonster.com
 
D

Douglas J. Steele

I don't believe it's possible.

However, note that your where condition is (I think) invalid.

I'm assuming that PictID is a field in TBL Backgrounds, and that you're
trying to get the image where PictID is equal to whatever value is in Chk.
Assuming Chk is a variable (and PictID is a numeric field), that should be

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = " & Chk)

If PictID is text, it should be

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = '" & Chk & "'")

If Chk is a control on the form, it should be

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = " & Me.Chk)

or

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = '" & Me.Chk &
"'")
 
C

Ceebaby via AccessMonster.com

Douglas

I really appreciate your response. I have been going nuts trying to see if
this works.

I am trying to think of another way of loading a picture background into a
form on the oncurrent event when a user selects a value from a combo box to
tell them visually a case is closed.

I don't want to use external path referencing as I have already had problems
with users moving the directory by accident and errors occuring saying they
cannot find the dir where the images are.

There are only 3 image records in the table so I thought if I could make the
forms picture property reference the required record, then I would not have
the problem of missing links via moved or deleted image folders.

Therefore I am trying to find a way to reference an jpeg, bitmap or gif image
embedded in a table to a forms picture property.

I hope this makes sense and do you know if this can be done instead.

Cheers again



I don't believe it's possible.

However, note that your where condition is (I think) invalid.

I'm assuming that PictID is a field in TBL Backgrounds, and that you're
trying to get the image where PictID is equal to whatever value is in Chk.
Assuming Chk is a variable (and PictID is a numeric field), that should be

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = " & Chk)

If PictID is text, it should be

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = '" & Chk & "'")

If Chk is a control on the form, it should be

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = " & Me.Chk)

or

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = '" & Me.Chk &
"'")
[quoted text clipped - 16 lines]
Thanks in advance
 
D

Douglas J. Steele

Sorry, it's not something I've ever bothered doing, and I'm afraid I don't
have the time to investigate at the moment.

Hopefully someone else can offer a solution.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Ceebaby via AccessMonster.com said:
Douglas

I really appreciate your response. I have been going nuts trying to see if
this works.

I am trying to think of another way of loading a picture background into a
form on the oncurrent event when a user selects a value from a combo box
to
tell them visually a case is closed.

I don't want to use external path referencing as I have already had
problems
with users moving the directory by accident and errors occuring saying
they
cannot find the dir where the images are.

There are only 3 image records in the table so I thought if I could make
the
forms picture property reference the required record, then I would not
have
the problem of missing links via moved or deleted image folders.

Therefore I am trying to find a way to reference an jpeg, bitmap or gif
image
embedded in a table to a forms picture property.

I hope this makes sense and do you know if this can be done instead.

Cheers again



I don't believe it's possible.

However, note that your where condition is (I think) invalid.

I'm assuming that PictID is a field in TBL Backgrounds, and that you're
trying to get the image where PictID is equal to whatever value is in Chk.
Assuming Chk is a variable (and PictID is a numeric field), that should be

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = " & Chk)

If PictID is text, it should be

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = '" & Chk &
"'")

If Chk is a control on the form, it should be

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = " & Me.Chk)

or

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = '" & Me.Chk &
"'")
[quoted text clipped - 16 lines]
Thanks in advance
 
S

Stephen Lebans

There are several methods available. Here are two:

1)
Load the three Images, one at a time, into an Image control. Save the
PictureData property of the loaded Image control into a table containing a
field of Long Binary type. Load your next picture.
At runtime, simply copy the contents of the appropriate record directly into
the PictureData property of the Image control on your form.


2) Create a form containing three Image controls. Open this form during the
loading of your app. Set the form's Visible prop to No.
At runtime, copy the PictureData property of the desired Image control on
your hidden form into the PictureData propery of the Image control on your
data entry app.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Ceebaby via AccessMonster.com said:
Douglas

I really appreciate your response. I have been going nuts trying to see if
this works.

I am trying to think of another way of loading a picture background into a
form on the oncurrent event when a user selects a value from a combo box
to
tell them visually a case is closed.

I don't want to use external path referencing as I have already had
problems
with users moving the directory by accident and errors occuring saying
they
cannot find the dir where the images are.

There are only 3 image records in the table so I thought if I could make
the
forms picture property reference the required record, then I would not
have
the problem of missing links via moved or deleted image folders.

Therefore I am trying to find a way to reference an jpeg, bitmap or gif
image
embedded in a table to a forms picture property.

I hope this makes sense and do you know if this can be done instead.

Cheers again



I don't believe it's possible.

However, note that your where condition is (I think) invalid.

I'm assuming that PictID is a field in TBL Backgrounds, and that you're
trying to get the image where PictID is equal to whatever value is in Chk.
Assuming Chk is a variable (and PictID is a numeric field), that should be

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = " & Chk)

If PictID is text, it should be

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = '" & Chk &
"'")

If Chk is a control on the form, it should be

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = " & Me.Chk)

or

test = DLookup("[Picture]", "[TBL Backgrounds]", "[PictID] = '" & Me.Chk &
"'")
[quoted text clipped - 16 lines]
Thanks in advance
 
C

cesima via AccessMonster.com

Dear Stephen

Thank you for your help it is very much appreciated, it works really well. I
used the 2nd method.

I have just seen your post and so apologies for the delay in responding.

Best wishes
Ceebaby


Stephen said:
There are several methods available. Here are two:

1)
Load the three Images, one at a time, into an Image control. Save the
PictureData property of the loaded Image control into a table containing a
field of Long Binary type. Load your next picture.
At runtime, simply copy the contents of the appropriate record directly into
the PictureData property of the Image control on your form.

2) Create a form containing three Image controls. Open this form during the
loading of your app. Set the form's Visible prop to No.
At runtime, copy the PictureData property of the desired Image control on
your hidden form into the PictureData propery of the Image control on your
data entry app.
[quoted text clipped - 55 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top