Results 1 to 6 of 6
  1. #1
    Guerra67 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2014
    Posts
    9

    Changing the background property on a subform

    MainForm - MainProspectFrm
    SubForm - SubDocTaskListProsp

    Forms!MainProspectFrm!SubProspectDocList.Form![CONTRACT].BackColor = RGB(255, 255, 0)

    I want to change the Toggle button [contract] "yellow" if previous statement is true

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Programmatically changing properties of controls on form only works nice if form is in Single view or the controls are in header/footer of Continuous form.

    What is the issue? What happens when this code runs?
    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
    Guerra67 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2014
    Posts
    9
    Nothing. No error code and the color does not change.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Not sure will make a difference, but I use dot (.) when referencing controls, and bang (!) when referencing fields. Could use vbYellow.

    Forms!MainProspectFrm!SubProspectDocList.Form.[CONTRACT].BackColor = vbYellow

    What do you mean by 'if previous statement is true'?
    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
    Guerra67 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2014
    Posts
    9
    Thanks the toggle button still does not change to yellow. I would like for the user to click on the check box which puts up a message box. Based on the result I want to change the color of the toggle button. There are multiple buttons on the subform.
    I would like to do this from a click event.
    Also my 2 fields CONTRACTREQDATE AND CONTRACTREQEMP are not staying locked once i save/close and open the form once more.
    Dim CResponse As Integer
    CResponse = MsgBox("Please confirm that you have REQUESTED the CONTRACT?", vbYesNo, "Continue")


    If CResponse = vbYes Then
    CONTRACTREQDATE = Now()
    CONTRACTREQEMP = CurrentUser
    CONTRACTREQchk.Value = True
    'Forms!MainProspectFrm!SubProspectDocList.Form![CONTRACT].BackColor = RGB(255, 255, 0)
    Forms!MainProspectFrm2!SubProspectDocList.Form.[CONTRACT].BackColor = vbYellow
    Me.CONTRACTREQDATE.Locked = True
    Me.CONTRACTREQEMP.Locked = True

    Else
    MsgBox "Please Return when you have the correct information", 0, "Gotcha!"
    CONTRACTREQDATE = ""
    CONTRACTREQEMP = ""
    CONTRACT.Value = False
    Me.CONTRACTREQDATE.Locked = False
    Me.CONTRACTREQEMP.Locked = False
    End If
    Last edited by Guerra67; 11-18-2014 at 01:18 PM. Reason: more information

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    If you want the textboxes locked when form opens, need to run the same code that looks at value of checkbox or use Conditional Formatting.

    The checkbox is on main form and toggle button is on subform?

    I always give subform container control name different from the object it holds, like ctrDocs. Then:

    Me.ctrDocs.Form.[CONTRACT].BackColor = vbYellow
    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. Replies: 5
    Last Post: 06-28-2013, 06:11 PM
  2. changing background multipleform
    By gunterhoflack in forum Programming
    Replies: 7
    Last Post: 01-15-2013, 11:47 AM
  3. Changing background image by date range
    By Monterey_Manzer in forum Forms
    Replies: 4
    Last Post: 09-27-2012, 11:52 AM
  4. Replies: 3
    Last Post: 01-04-2012, 05:16 PM
  5. Changing scrolling field background
    By JeffG3209 in forum Access
    Replies: 0
    Last Post: 05-10-2011, 08:56 PM

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