Change picture background on a form on afterupdate event

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

Ceebaby via AccessMonster.com

Hi Folks
Hope someone can help on this.
I have a form that where I want the picture background to change on the
afterupdate event of a field, eg where if the case status is - closed, live,
or pending, the backgrounds will change to blue, red or green for example.

I have created a table called TBL Backgrounds, with 3 OLE image records and
the imageID is the PK. I also have a corresponding form to insert the jpeg.
There will only ever be 3 image records in this table.

Blue imageID =1
Red imageID= 2
Green imageID=3

I want to be able to change another forms picture by referencing the
appropriate record from the Background form. eg

if me!CaseStatus ="Close" then change the background to green which
would be imageID = 3
elseif me!CaseStatus ="live" then change to blue etc etc

I don't want to reference externally, as I have had problems with users
moving/deleting the folder where the images are, and as it is only 3 records
we can cope with the database bloat. All other images are referenced
externally by pathfile.

I have tried dlookup but am not sure what the variable to declare to be able
to return an jpeg image

This seems so simple, I just can't understand why I can't get my head around
this.
Any ideas?
Thanks in advance
 
G

Guest

Why are you trying to use images??? They bloat the database.

You could change the color of the detail section or you could add a box to
the detail section and change the color of the box. You could add a label and
change the properties of the label (caption, font color, back color, size,
position, visible).

It sounds like the form is in "Single Form" view. Try this: add a box to the
detail section that covers all of the controls. Name it "Box3". Set the
BackStyle to NORMAL. Send it to the back so that the controls are "on top" of
the box
(On the menu bar: Format/Send to Back).

Add this code to the Current event of the FORM:


Private Sub Form_Current()
Const vGray = -2147483633

Select Case Me.CaseStatus
Case "Close"
Me.Box3.BackColor = vbGreen
Case "pending"
Me.Box3.BackColor = vbRed
Case "Live"
Me.Box3.BackColor = vbBlue
Case Else
Me.Box3.BackColor = vGray
End Select
End Sub



As you scroll thru the records the box back color will change.

HTH
 
C

Ceebaby via AccessMonster.com

Hi Steve

Thank you so much for the response. You totally understood what I was trying
to do.

I eventually worked out how to do this but your code is much neater than mine.


I only have these 3 images for the forms backgrounds in the database, all
other images are externally referenced to avoid database bloat. The reason I
thought it would be best to have the 3 images in the database was due to
problems I had with users moving the the folder the background images were in
which caused error messages.

It works a treat and thanks once again you stopped me tearing my hair out.
Have a good day

Ceebaby
London


However

Steve said:
Why are you trying to use images??? They bloat the database.

You could change the color of the detail section or you could add a box to
the detail section and change the color of the box. You could add a label and
change the properties of the label (caption, font color, back color, size,
position, visible).

It sounds like the form is in "Single Form" view. Try this: add a box to the
detail section that covers all of the controls. Name it "Box3". Set the
BackStyle to NORMAL. Send it to the back so that the controls are "on top" of
the box
(On the menu bar: Format/Send to Back).

Add this code to the Current event of the FORM:

Private Sub Form_Current()
Const vGray = -2147483633

Select Case Me.CaseStatus
Case "Close"
Me.Box3.BackColor = vbGreen
Case "pending"
Me.Box3.BackColor = vbRed
Case "Live"
Me.Box3.BackColor = vbBlue
Case Else
Me.Box3.BackColor = vGray
End Select
End Sub

As you scroll thru the records the box back color will change.

HTH
Hi Folks
Hope someone can help on this.
[quoted text clipped - 29 lines]
Any ideas?
Thanks in advance
 

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