Results 1 to 3 of 3
  1. #1
    Odelphi is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Location
    South
    Posts
    1

    change color of form during runtime

    Sorry if this has already been answered. I did a search and didn't find anything that specifically answered this question. I would like to be able to allow my users to change the color of a form during runtime. I have already programmed the code to bring up a color palette and change the color of a hard-coded part of the form (specific control, detail, formheader, formfooter, etc). However, I would like to let the user click (or double click) anywhere on a form (in a control or on the form itself[detail, formfooter, formheader) and change the color of the part of the form they have clicked on. A user-friendly way to do this is when the user clicks on the form or control a color palette pops up and allowed them to pick a color.
    My db has several forms in various formats - master-child forms, single forms, continous forms, datasheet forms, forms with and without headers and footers. Starting in A2007, you can also set the backcolor and/or the alternatebackcolor. I don't know how to tell the database where I clicked in order to tell the color palette what to change. Another problem I am encountering is that, as mentioned earlier, I can already change the color of a hard-coded part of the form (I push a button on a form, which brings up the color palette, when I click OK on the color palette, it changes an already hard coded part of the form). However, when I close the form and reopen it, the color reverts back to the default color. How do I get it to save the color after I close then reopen the form.

    Thanks

  2. #2
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Did you get any help with this? I notice that your post is unanswered and 3 weeks old.

    I don't know why you want to do this but I'm willing to help; there's more than one issue here and, if I'm not mistaken, an API.

  3. #3
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    In order to do this, i.e. make the changes permanent, you have to open the form in design view, make the change, and save the modified form. This can be done in VBA quite easily - This bit of code, which I just tried, works fine in A2003, using a command button on the form to be changed:

    Private Sub Command14_Click()
    'On Error GoTo Err_Command14_Click

    Dim frm As Form
    DoCmd.Close ' Close the form
    DoCmd.OpenForm "Form1", acDesign ' re-open the form in design view
    Forms.form1.Detail.BackColor = 255 ' make the required change
    DoCmd.Close , , acSaveYes ' close the form and save the change
    DoCmd.OpenForm "form1", acNormal ' re-open the form in form view
    Exit_Command14_Click:
    Exit Sub

    Err_Command14_Click:
    MsgBox Err.Description
    Resume Exit_Command14_Click

    End Sub

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

Similar Threads

  1. Replies: 4
    Last Post: 09-04-2012, 07:41 PM
  2. Change color on a button on a form
    By helpme1 in forum Forms
    Replies: 1
    Last Post: 01-13-2012, 12:59 PM
  3. Change the text box color on form load
    By mikec in forum Programming
    Replies: 2
    Last Post: 03-01-2010, 11:47 PM
  4. Color change in form filed
    By miziri in forum Programming
    Replies: 3
    Last Post: 08-15-2009, 04:53 PM
  5. change cell color
    By bishop743 in forum Programming
    Replies: 0
    Last Post: 02-01-2009, 11:00 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