Results 1 to 4 of 4
  1. #1
    Zipster1967 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2006
    Location
    Wisconsin
    Posts
    19

    Question Image type form that displays cubicle of search result?

    I am trying to create a map type form that will use the rectangle control to represent all the different cubes in an office building and I would like the cube that the person is searching for based on the employee look-up table to change either the rectangle color of the corresponding cubicle or to display an arrow. Are either of these things possible? If not how would I go about accomplishing something similar? Any ideas? Thanks in advance for any help.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Yes, I think this could be done. You have a combobox or listbox where user enters search criteria. Then VBA code in the AfterUpdate event sets the background color property of the correct rectangle. The code could be a Select Case structure. Or if you use textboxes as the rectangles can take advantage of conditional formatting, no VBA needed for that. Background color would be conditional on value in combobox.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Zipster1967 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2006
    Location
    Wisconsin
    Posts
    19
    That sounds pretty simple. Now is where it gets complicated. In this situation I might have two Sarah Johnson's working for the company one in the HR Department on the fifth floor and one in R&D on the 7th floor. I have my form designed to let the person searching to add the department to narrow the resulting results if they know it, but if they don't enter any other information but the name the form will list multiple records of both Sarah Johnsons. Can I have the form display the form with different highlights when they select different records in the subform display? (That is what I am using to display the multiple results) BTW. Thanks for the info. Any hints on how to structure the code. (I am not a great VBA coder by any stretch of the imagination.)

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Probably could be done. So in a button click event, follow this logic:

    1. set color property of all rectangles to default. This is needed if you allow multiple searches and want the display reset for each search. In other words, search for Smith, form stays open, now reset and Search for Jones. If you don't reset then both rectangles will be colored.

    2. Loop code to process all selected records and highlight relevant rectangle.

    Rough code example. Presumes a recordset filtered to only records meeting search criteria.
    Code:
     
    Private Sub btnHighlightRectangles_Click()
     
    Dim cn As ADODB.Connection
    Dim rs As DAO.Recordset
    Dim n As Integer
    Set cn = CurrentProject.Connection
    Set rs = Me.ctrEmplList.Form.RecordsetClone
     
    'code to set rectangles to default backcolor; name the rectangles similar like rec1, rec2, etc
    For n = 1 to total number of controls here
        Me.Controls("Rec" & i).BackColor = vbWhite
    Next
     
    'alternate code using Controls collection
    'not tested and not sure of syntax
    'required if rectangle name includes room number
    Dim c As Control
    For Each c In Me.Controls
    If c.Name Like "rec*" Then c.BackColor = vbWhite
    Next
     
    'code to read each record of filtered recordset and set color of rectangle
    rs.MoveFirst
    While Not rs.EOF
        Select Case rs!RoomNo
            Case 111A
                Me.rec1.BackColor = vbGreen
            'continue for other rooms
        End Select
        rs.MoveNext
     
        'alternate to the Select Case if rectangle names follow room number structure
        Me.Controls("rec" & rs!RoomNo).BackColor = vbGreen
     
    Wend
     
    End Sub
    Last edited by June7; 06-07-2011 at 01:44 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Search engine result database suggestions
    By PIHA520 in forum Access
    Replies: 0
    Last Post: 05-29-2011, 05:44 PM
  2. Binding a Combo Box Search Result
    By cvansickle in forum Forms
    Replies: 2
    Last Post: 12-06-2010, 11:03 AM
  3. Image Buttons Menu type form
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-30-2010, 10:17 PM
  4. Form displays ID number, not data
    By Twimm in forum Forms
    Replies: 5
    Last Post: 07-13-2010, 03:04 PM
  5. Search result links adding extra info
    By Vbcw in forum Programming
    Replies: 0
    Last Post: 12-19-2008, 12:19 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums