Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232

    command button

    Hi I have created command buttons to open another form (customer record has a command form that is called proposal which will open the proposal form so you can enter data for that customer) I would like to have the command button to change color if there is data entered in the form. So one color is form is null and another color is it not null.
    Thanks

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Just typiing while thiinking --- UNTESTED BUT SOMETHING ALONG THIS __

    When you open or load the form, can you check to see if a particular field is populated

    You could do a query with specifics.
    On Form Open...
    if TheField >" " Then
    me.cmdButton.Forecolor = 66666
    else
    me.cmdbutton.Forecolor = your default
    endif

  3. #3
    robrich22's Avatar
    robrich22 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Location
    Louisville, KY
    Posts
    41
    I'm not sure if this is what you are looking for.. But this will check to see if any records exist in the table "tblProposal", and if records exist
    then it will change the color of the text on the button. You could put this code in the Load event of the Form.


    Please elaborate more if, this is not helpful. Thanks

    Code:
    Private Sub ButtonColors()
        Dim records = DCount("*", tblProposal)
    
    
        if(records > 0) Then
           cmdProposal.ForeColor = vbGreen
        End If
    End Sub

  4. #4
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Thank you I will try it and let you know

  5. #5
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    I have tried the above code both in the form with the proposal button and the proposal form. The = causes a error. Maybe I am not doing something right.

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Why not just show the "Proposal" form on the customer form as a sub form, linked by CustomerID, which would then show if there are any records in the Proposal table.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    I am trying to stay away from sub forms . I have created a database for our heating and ac company that includes invoicing, scheduling , proposals , and a lot more. I have added to it over the years. It has everything that a company needs to run a heating and air company more than anything on the market. I have taught myself to code and create the database ( with help from people like you " very grateful for"). So now I am trying to update to the access 2013 and improve it again. So I wanted to try and make it better.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    What exactly is/are the feature(s) of ACC2013 that you will get to improve your database?

    I'd like to see a jpg of your tables and relationships, could you post same?

    I am trying to stay away from sub forms .
    Can you tell us more about this? Form/subform is a designed-in feature of Access that is "relatively" easy to set up with tables in a 1 to many relationship.

  9. #9
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    I do have subforms already on the main customer form did not want to add anymore. Also I was using access 2007 and upgraded to 2013. I have this database split and networked so everyone can work at the same time. I am not to happy that the calendar control was missing ( but was able to add it back in ). I have added a button with a command to open mapquest and go the address for the customer that is open at the time. Also I have created a button to open a folder on the network that stores scanned documents in folders for each customer and it opens only that customer folder. So you can see I have spent a lot if time to get it just right for our type of business. But I was trying to tweak some details in the database to give it a fresh look. I love this site because it gives me fresh and new ideals.

  10. #10
    ipisors is offline Access Developer
    Windows XP Access 2007
    Join Date
    Sep 2013
    Posts
    119
    Why not just use conditional formatting and skip the code altogether?

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    What exactly does acc2013 give you that you didn't have in acc2007? Just curious.

  12. #12
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Please explain

  13. #13
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Orange, It allows more options for command shapes. I am thinking maybe in design only. I have just started working with 2013 so not real sure. In the old database I have the main form customers with a command button that opens proposals . In the proposal form there is a check box on the customer form that will be checked only when data is completed in the proposal form. I wanted to do away with the check box and have the proposal button to change font color or become bold if proposal form is completed.

  14. #14
    robrich22's Avatar
    robrich22 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Location
    Louisville, KY
    Posts
    41
    Quote Originally Posted by angie View Post
    I have tried the above code both in the form with the proposal button and the proposal form. The = causes a error. Maybe I am not doing something right.
    Sorry I was typing too fast and not thinking.. Gave you bad code Try the code below. This will get the count of records from a table named "tblProposals". If the count is greater than 0, then it changes the button properties that I listed. You can play around with it. It works.

    Code:
    Private Sub ChangeButtonColors()
        Dim records As Integer
        records = Nz(DCount("*", "tblProposals"), 0)
    
        If (records > 0) Then
           cmdProposal.ForeColor = vbRed
           cmdProposal.FontBold = True
           cmdProposal.FontSize = 14
        End If
    End Sub

  15. #15
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Hi I tried your last update But it will still not change the color of the command button
    This is what I added to the form where the command button is located.
    I think I might be doing something wrong.


    Private Sub Form_Load()
    Dim records As Integer
    records = Nz(DCount("*", "tblProposal"), 0)
    If (records > 0) Then
    cmdProposals.ForeColor = vbRed
    cmdProposals.FontBold = True
    cmdProposals.FontSize = 14
    End If
    End Sub

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 08-04-2013, 07:11 AM
  2. Command Button Help
    By emailloni in forum Forms
    Replies: 5
    Last Post: 07-30-2012, 09:16 AM
  3. Button Command
    By JayX in forum Access
    Replies: 7
    Last Post: 12-27-2011, 12:58 PM
  4. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  5. Command Button Help!
    By arthura in forum Programming
    Replies: 3
    Last Post: 06-30-2009, 12:55 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