By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 2,763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

MS Access: Show Image Based on Condition (Date Field)

P: 1
Hello Everyone!

This is my first post to the forum.

---------------------------------------------------------------------------------------------

In my database, I have a continuous subform called: "subCallBack". I setup my query, so that it only shows records that do contain a date value, in the "lsrCallBackDate" column.

Any record within this subform, is one of our customers that our employee needs to call on a certain date. Even though each record is sorted (A~Z) by Call Back Date - I would like a visual indication telling the user which records require a call back today.

Image: "imgCallBackToday" [Visible: No]
Text Box: "txtCallBackDate"

If the Call Back Date of the record equals Today(), then I want the image to appear. If it does not match, then I want the image to stay invisible.

I would also like this image to be stored within a folder on the network where the Back End of my database is.

When I mention Today, I don't mean today as in: 04-26-06 - but Today() as in a rolling date. (Hope that makes sense...)

I have posted this question over at a paid forum I belong to, but none of the solutions that were provided to me worked correctly.

Thank you in advance for your help.

---------------------------------------------------------------------------------------------

Important Note:
When you respond to my question, please assume I know nothing about MS Access. My skill level, is a beginer & I tend to get lost very easily. :confused:
Apr 26 '06 #1
Share this Question
Share on Google+
1 Reply


100+
P: 135
First off, is your form "bound" to the database? (By that I mean, do you click a "data control" to cycle through the records)

If so, I assume you have a text field that shows you the date in which the call back date is based on.

If that is the case then the following should get you started, it might be a little complicated at first till you get the general idea once you start.

In design mode for the form you should see a "Toolbox" on the left that has text boxes, labels etc. for designing the form. One of those controls is for images. Click on that and place it on your form where you want it. It will ask you where the image is you want to show in it. Navigate to the image located in the folder on your "Back end server".

Now, MS Access has a means to enter "VBA" code to do things you can not from the simple design mode. (Click "View" - "Code")

VBA code runs off "Events"

Clicking a button runs the Button_Click() event

When a Form loads it activates the Form_Load() event

When you change the records on the form with the data control it activates the Form_Current() event

Go into "View" "Code" and you will see two drop downs. Click the left drop down and select "Form" and it should put you in the form_Load event.

Now click to right "drop down" and select "Current" that will put you in the Form_Current() event.

In the form current event enter the following changing the text box name and image control names to yours.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. On Error GoTo ErrHandler
  3.  
  4.     If txtDate.Text = Date Then
  5.         MyImage.Visible = True
  6.     Else
  7.         MyImage.Visible = False
  8.     End If
  9.  
  10. ErrHandler:
  11.     MsgBox "Error detected, error # " & Err.Number & ", " & Err.Description, vbOKOnly, "Error"
  12. End Sub
  13.  
Now run the form and cycle through the records and see what happens.
Apr 26 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.