Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2013
    Posts
    2

    Question Unanswered: show image depending on a calculation

    Hi everyone. I'm quite new to Access, my field is JavaScript so I'm a little stuck. I have created a database that is quite simple, just to keep a DB of cancelled clinics. I have a query that returns all clinics cancelled from now to the next 6 weeks, and another that shows cancellations for the next 15 weeks. The criteria in the date is: Between Now() And DateAdd("ww",6,Date()).

    My question is: How can I bring a red flag image up visible on the form if the data entered from date to date if less than 6 weeks?

    Thanks in advance

    SmiffySan

  2. #2
    Join Date
    Jan 2009
    Location
    Kerala, India
    Posts
    183
    1. Create and save the image on disk: say at c:\images\1.jpg
    2. Create an Image control on the form where you want the image to appear (say image control name: Image13)

    In the following sample Code I check the current value of Text box Name: Text9 in the AfterUpdate() Event Procedure:

    Code:
    Private Sub Text9_AfterUpdate()
    Dim x
    x = Nz(Me![Text9], 0)
    If x < 6 Then
       Me.Image13.Picture = "c:\images\1.jpg"
    Else
       Me.Image13.Picture = ""
    End If
    
    End Sub
    You may modify the Code.
    www.MsAccessTips.com (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

  3. #3
    Join Date
    Jan 2009
    Location
    Kerala, India
    Posts
    183
    Quote Originally Posted by apr pillai View Post
    1. Create and save the image on disk: say at c:\images\1.jpg
    2. Create an Image control on the form where you want the image to appear (say image control name: Image13)

    In the following sample Code I check the current value of Text box Name: Text9 in the AfterUpdate() Event Procedure:

    Code:
    Private Sub Text9_AfterUpdate()
    Dim x
    x = Nz(Me![Text9], 0)
    If x < 6 Then
       Me.Image13.Picture = "c:\images\1.jpg"
    Else
       Me.Image13.Picture = ""
    End If
    
    End Sub
    You may modify the Code.
    The image c:\images\1.jpg is loaded into the image control when the value in Text9 is less than 6 otherwise the image control is loaded with an empty string.
    www.MsAccessTips.com (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

  4. #4
    Join Date
    Nov 2013
    Posts
    2

    Perfect

    That's great, thanks very much.

  5. #5
    Join Date
    Nov 2012
    Posts
    32
    Unless you are dealing with large quantities of large images, I wouldn't advise storing the images separate from the database, just insert the image to the form and then in VBA you can reference it just with a name.

    So instead of
    Me.Image13.Picture = "c:\images\1.jpg"
    you can just use
    Me.Image13.Picture = "1"
    without having to worry about your directory structure

    Btw, Text9, Image13, 1.jpg? Not very descriptive

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •