Need a bit of Help!

I

Isaac Sanchez

I have a form that shows an image using the following code:

Private Sub FORM_CURRENT()
On Error GoTo Err_Handler
If Len(CStr(Nz(Me.Text42, "")) & CStr(Nz(Me.DISPLAYER, ""))) > 0 Then
Me.Image46.Picture = "K:\DB\Maps\" & CStr(Me.DISPLAYER) & ".BMP"
Else
Me.Image46.Picture = ""
End If
Exit_Handler:
Exit Sub
Err_Handler:
If Err.Number <> 2501 Then
Me.Image46.Picture = "K:\DB\Maps\1 NO MAP.BMP"
End If
Resume Exit_Handler
End Sub

I need the ability to override the image with the use of a text box and/or
if needed a check box. I tried to figure it out but I've been unsuccessful.
Not sure how to properly tweak the code

To be honest I don't even know why
"If Len(CStr(Nz(Me.Text42, "")) & CStr(Nz(Me.DISPLAYER, ""))) > 0 Then"
is required for the thing to work. I tried to take it out cause there is
always
a name in the "DISPLAYER" field but it will not work with out it.

So how would I incorporate my over ride into the code.

All help will be greatly appreciated.
Isaac Sanchez
 
K

kingston via AccessMonster.com

What is Me.Text42 supposed to do? The conditional (If ... Then) may not be
needed if you're positive that Me.DISPLAYER always has a value; however,
you'll need to get rid of everything from If to End If except for:
Me.Image46.Picture = "K:\DB\Maps\" & CStr(Me.DISPLAYER) & ".BMP"

If you add a check box control to your form (or use Me.Text42 somehow), use
its AfterUpdate event to override the image. So, if the box is checked (=-1)
or unchecked (=0), you can set the image to nothing via:
Me.Image46.Picture = ""
or to a default image:
Me.Image46.Picture = "K:\DB\Maps\1 NO MAP.BMP"
 
T

TonyT

Hi Isaac,

If you have a textbox and a checkbox already in place, make them invisible,
and use
Me.TextBox.Visible = True
Me.Image46.Visible = False
In the appropriate event procedure - depends when you want the ability to
override the picture, you could do it in the same procedure with a msgbox.

How did you try to remove the Len(CStr(Nz.......... coding, it looks like it
should work fine with just;
If not IsNull(Me.DISPLAYER) Then
Me.Image46.Picture = "K:\DB\Maps\" & CStr(Me.DISPLAYER) & ".BMP"
Else
Me.Image46.Picture = ""
End If

but then I can't see whats in Text42 and why it might have relevance.

TonyT..
 
I

Isaac Sanchez

Thanks for the Help, I ended up with this:

Private Sub FORM_CURRENT()
On Error GoTo Err_Handler
If Len(CStr(Nz(Me.DELIN, ""))) > 0 Then
Me.Image46.Picture = "K:\DB\Maps\" & CStr(Me.DELIN) & ".BMP"
Else
Me.Image46.Picture = "K:\DB\Maps\" & CStr(Me.DISPLAYER) & ".BMP"
End If
Exit_Handler:
Exit Sub
Err_Handler:
If Err.Number <> 2501 Then
Me.Image46.Picture = "K:\DB\Maps\1 NO MAP.BMP"
End If
Resume Exit_Handler
End Sub

And It works exactly the way I need it to.

Regards,
Isaac Sanchez
 
Top