Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Morecambe England, Lancashire, England
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Making a comand button sunken (Access 2000/Windows XPpro)

    Hi
    I have a little button on a form that opens a list of contacts. No problems there and it works well. The button toggles the words it shows and to make if clearer it goes Blue and bold when it's open and goes back to black when it's clicked again. This is the code and I want to make some improvements!

    If Me.CmdContacts.Caption = "Open Contacts" Then
    CmdContacts.ForeColor = vbBlue
    CmdContacts.FontBold = True
    DoCmd.OpenForm stDocName
    Me.CmdContacts.Caption = "Close Contacts"
    Else
    DoCmd.Close acForm, stDocName
    Me.CmdContacts.Caption = "Open Contacts"
    CmdContacts.FontBold = False
    CmdContacts.ForeColor = -2147483630
    End If

    In a diferent database, I found that using the form wizard it was possible if you told it to create seperate linked form to have a command button that toggles it's state from raised to sunken and I cannot work out a way to do it for my contacts button

    I know this is the code that the wizard uses:-
    Private Function ChildFormIsOpen()

    ChildFormIsOpen = (SysCmd(acSysCmdGetObjectState, acForm, "TblPost Charges1") And acObjStateOpen) <> False

    End Function

    However in my instance the two forms are not liked and in fact have nothing to do with each other, just a quick way to get names and telephone numbers so I can't use "ChildFormIsOpen"

    Anyone any ideas please?

    Thanks in anticipation

    Incidently the original idea for toggling the button name came from Hans a good while ago, and it's really useful and I use it a lot .

    Michael Peak
    Morecambe - England

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Making a comand button sunken (Access 2000/Windows XPpro)

    Instead of a command button, you can use a toggle button - as the name indicates, it can be toggled on and off.

  3. #3
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Morecambe England, Lancashire, England
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making a comand button sunken (Access 2000/Windows XPpro)

    Hi Hans

    What a good thing it is to have people like you around for such great help

    As I'm quite sure you know it works and just for the record here is the changed code

    If Me.TglOpenContacts.Caption = "Open Contacts" Then
    TglOpenContacts.ForeColor = vbBlue
    TglOpenContacts.FontBold = True
    DoCmd.OpenForm stDocName
    Me.TglOpenContacts.Caption = "Close Contacts"
    Else
    DoCmd.Close acForm, stDocName
    Me.TglOpenContacts.Caption = "Open Contacts"
    TglOpenContacts.FontBold = False
    TglOpenContacts.ForeColor = -2147483630
    End If

    With best wishes and once more thanks for your help

    Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •