Display Icon Depending on Field's Value

JamesJoey

Registered User.
Local time
Today, 17:06
Joined
Dec 6, 2010
Messages
642
I have a reminders table for appointments and tasks.
There are 2 types of reminder: calendar event and task.
In a continuous form based on reminders I want to display a control that displays 1 of 2 icons depending on whether the reminders is a calendar event or a task.
I'm not quite sure how tro get this accomplished.
Should I create a field in the table or create an unbound text box and check for the reminder type?
The reminder types are in a lookup table linked to the reminders table.

Thanks,
James
 
use an image control bound to a value in your form recordsource query which determines the path to the image. e.g. your recordsource might be something like

SELECT *, "c:\images" & iif([reminder]="calendar","calendar","task") & ".jpg" as imagetype
FROM myTable

you would then bind the image control to the imagetype field

or store the path in your lookup table and just bring it through in your query
 
An alternative that may be easier is, rather than an icon use a label and set back ground colour and caption based on what type of reminder it is.

Code:
IF [Reminder] = "Calendar" then
   me.LblReminder.Color = vbBlue
   me.LblReminder.Caption = "C"
Else
   me.LblReminder.Color = vbGreen
   me.LblReminder.Caption = "T"
End If

This avoids dealing with an external file.
 
I put the following in the On Load of the form but the color stays green:

Code:
If [ReminderTypeID] = 1 Then
   Me!lblReminerTypeIndicator.BackColor = vbRed
Else
   Me!lblReminderTypeIndicator.BackColor = vbGreen
 End If

The 1 is the ReminderTypeID value linked to the lookup table In the relationship.
 
Check your spelling

Code:
If [ReminderTypeID] = 1 Then
   Me!lblRemin[B][COLOR="Red"]d[/COLOR][/B]erTypeIndicator.BackColor = vbRed
Else
   Me!lblReminderTypeIndicator.BackColor = vbGreen
 End If
 
I fixed the spelling but the same thing:

Code:
If [ReminderTypeID] = 1 Then
   Me!lblReminderTypeIndicator.BackColor = vbRed
 
   Else
   Me!lblReminderTypeIndicator.BackColor = vbGreen
 
End If

I placed the ReminderTypeID on the form and it shows 1 for Calendar Event and 2 for Task.
 
Not for the current record.
For all records in the continuous form.
 
Try changing the first line to

If Me.ReminderTypeID=1 Then

BTW if its a test field, add text delimiters
 
JamesJoey,

Please put the code I posted into the form's Detail On Paint event. I'm not use to using continuous forms so I hadn't realized it needed to be in the detail.
 
I added a text box to the table and placed it on the form.

I created 2 rules using conditional formatting one for 1 (calendar event) and one for 2 (task).

That doesn't work either.

Very confusing.
 
JamesJoey,

Did you try the Detail's On Paint event?
 
I pasted the Iff statement to the Detail's On Paint.

I kept getting the object doesn't support the property or method.

Every time I closed the error it popped up again.

I had to close Access from the Task Manager.

BTY, I misspelled again and the new bound textbox conditional formatting does work.
Not sure if this is a good way to do it.
 
Last edited:
JamesJoey,

Not sure if you figured this out. Please see the attached. You will want to look at the Form and its events on the form detail.
 

Attachments

Slight thread hijack apologies!

Does anyone have any experience if using the detail paint method is better/more efficient/less screen flicker prone, than conditional formatting?

I can test but looking to be Friday #lazy#.
 
Minty,
I haven't done a lot with it since I normally don't do continuous forms. My guess though, is it should be about the same unless Access does something really strange with conditional formatting.

That said I simply assign the colours in code so it should all be executed for each "Form" at one time.
 

Users who are viewing this thread

Back
Top Bottom