Results 1 to 5 of 5
  1. #1
    Vision's Avatar
    Vision is offline Novice
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Location
    Stuttgart, Germany
    Posts
    2

    How can I change the background color of a single record text box of a multiple item form?

    I have created a multiple item form for a simple table, not part of a relationship to any other table. I need help changing the color of a single record textbox control upon the mouse hovering inside the control. I would like to change the color to yellow (like PostIt Note yellow or RGB(255,255,204)). Then, when the mouse cursor is no longer focused on that particular text control for that individual record, the color returns to it's former color. My previous attempts at VBA code would change that text control for the entire field (i.e., every single text box turned yellow in that field). Here is what the multiple item form looks like:

    Click image for larger version. 

Name:	CustomerMultipleForm.jpg 
Views:	14 
Size:	42.5 KB 
ID:	21845

    So when my mouse hovers over the box with the "William" record in the [First Name] field, the background color of the text box containing "William" turns yellow, but nothing else turns yellow. So [Last Name], [Phone Number], etc would not change color and no other [First Name] record turns yellow either. Then, when my mouse leaves "William" and moves to "Steven", the "William" text box goes back to the original color and "Steven" becomes yellow, and so on down the [First Name] field. I feel comfortable with both Macro and VBA solutions.

    The following code is very close, but produced the wrong result, highlighting every record under the [First Name] field in the multiple item form, instead of just a single text box control of a single record.
    Code:

    Private Sub txtFirstName_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Not Me.txtFirstName.BackColor = vbYellow Then Me.txtFirstName.BackColor = vbYellow End Sub
    Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Not Me.txtFirstName.BackColor = vbWhite Then Me.txtFirstName.BackColor = vbWhite End Sub


  2. #2
    NGFLNG1 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Nov 2014
    Posts
    16

  3. #3
    Vision's Avatar
    Vision is offline Novice
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Location
    Stuttgart, Germany
    Posts
    2
    Quote Originally Posted by NGFLNG1 View Post
    Thank you NGFLNG1 for looking into this. This was one of the first websites I came across when I did the initial Google search for a solution. Unfortunately, Experts-Exchange stops short of providing a complete answer. There is an option to "View Next page" at the bottom of the weblink you provided, but when you go there, they try to get you to pay them money to see the rest of the solution. I'm big on freedom, but low on cash.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    That is why posting links to ExpertsExchange is discouraged.

    Unfortunately, what you want likely is not possible with form in continuous or datasheet view because programmatic setting of control property is reflected in all instances of that control.

    Conditional Formatting is the only way to change a control's appearance between records on a form and the feature you want is not available with Conditional Formatting.
    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.

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The closest you can come to this, with a Continuous or Datasheet View Form, is actually clicking into the Textbox, and using Conditional Formatting, as June7 said> Under 'Condition' select 'Field Has Focus'.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 4
    Last Post: 10-28-2014, 09:51 AM
  2. Replies: 7
    Last Post: 06-26-2014, 01:41 PM
  3. Replies: 2
    Last Post: 06-01-2014, 12:05 PM
  4. Replies: 3
    Last Post: 01-01-2014, 11:21 PM
  5. Change Row Background Color Programmatically
    By sales@4bco.com in forum Programming
    Replies: 2
    Last Post: 10-25-2009, 11:17 AM

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