Results 1 to 15 of 15
  1. #1
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776

    Active Screen Caption


    Hi all,
    I have the following in a line of code in a public function. How do I remove the ( & " :Edit Mode" ) from the caption on form once I leave edit mode?

    Screen.ActiveForm.Caption = Screen.ActiveForm.Caption & " :Edit Mode"

    Thanks
    Dave

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,655
    You just reset the caption to what you want in whatever event takes you out of edit mode.

  3. #3
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Screen.ActiveForm.Caption = Screen.ActiveForm.Caption

    I tried above but doesn't remove the & :Edit Mode. I am using Public Function so I need it to go back to just the Caption on current form in properties. It has to pick the current form caption.


  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    You will probably have to store the original/starting caption in a form level (form module) variable on form open so you can revert back to it. What you have posted is basically saying "it is what it is".
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Code:
    If right(screen.activeform.caption,4) = "MODE" then
        screen.activeform.caption = left(screen.activeform.caption,Len(Screen.activeform.caption)-10)
    end if

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,740
    Perhaps
    Code:
    Screen.ActiveForm.Caption = Replace(Screen.ActiveForm.Caption," :Edit Mode","")

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    If there are several modes (edit, new, delete) I would not write a similar expression for each when I could set the caption property in design and grab it on form opening. Especially when I could write that in a public sub and use it on every form in the db even if there's only one mode. Just seems more efficient to me.

  8. #8
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Micron
    I like that idea, there are several caption changes I want such as Add, Edit, and so on.... Having this work on every form is what I am looking to do. Do you possibly have an example of this?

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    No, never done it. If I haven't put my foot in my mouth (there is usually one there) I should be able to walk you through it. However, I know too little about your db at this point. It could be as simple as having a form level variable to which you assign the form caption as per form property sheet. Then you're modifying it with your function. No idea what "leave edit mode" means but that code would simply restore the form caption from the variable if you're not switching modes at that point. What then if you switch modes, assuming you can? If you're simply closing, this all seems pointless as the caption change won't be permanent unless you modify it in design view.

    BTW, I personally would not use Screen.ActiveForm unless I had to. It can result in unwanted and unpredictable effects, especially when the code isn't part of the form or report object, which is what you have here.

  10. #10
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,655
    Quote Originally Posted by d9pierce1 View Post
    Screen.ActiveForm.Caption = Screen.ActiveForm.Caption

    I tried above but doesn't remove the & :Edit Mode. I am using Public Function so I need it to go back to just the Caption on current form in properties. It has to pick the current form caption.

    Screen.ActiveForm.Caption = "Your new Caption Here"
    Screen.ActiveForm.Caption = Screen.ActiveForm.Caption is just taking the existing caption you already changed and setting it to the same thing.

    I agree with Micron about using screen.activeform. As I pointed out in one of your prior posts I find it much simpler to pass the form object to the procedure.

    You've been struggling with this in a couple different threads so I'm not sure how much of the advice you've been given has been incorporated into your code.
    It would help if you posted the entire code and even better if you post a stripped down example db with dummy data.

  11. #11
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    There is another thread somewhere on this same subject??

    Screen.ActiveForm.Caption = Screen.ActiveForm.Caption is just taking the existing caption you already changed and setting it to the same thing.
    That's what I meant when I said the expression was just saying the caption 'is what it is'. I should try to be less cryptic.

  12. #12
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    HI all,
    I have been struggling with this and want to get it correct for sure. I like the idea of having a public function on my buttons and navagation for most all my forms. However, I have checked into changing the Screen.ActiveForm method away but must be doing something wrong with the frm = Form to get around it as it doesn't work. I am new to this in all actuality so would definitely like to hear ways around this if anyone would like to comment or post any examples. I have attached a section of code at bottom and maybe if I get an example of something else I can over come this?
    Thank you all,
    Dave

    I guess what I am asking here is there a way to keep the button and navagation buttons in a public function that works well or is it actually better to keep everything in a private sub?

    Code:
    Public Function GotoCurrent()
        On Error Resume Next
        If Screen.ActiveForm.CurrentRecord = 1 Then
            Screen.ActiveForm.CmdPrevious.Enabled = False
            Screen.ActiveForm.CmdFirst.Enabled = False
        Else
            Screen.ActiveForm.CmdPrevious.Enabled = True
            Screen.ActiveForm.CmdFirst.Enabled = True
        End If
        If Screen.ActiveForm.CurrentRecord = Screen.ActiveForm.Recordset.RecordCount Then
            Screen.ActiveForm.CmdLast.Enabled = False
        Else
            Screen.ActiveForm.CmdLast.Enabled = True
        End If
        If Screen.ActiveForm.CurrentRecord >= Screen.ActiveForm.Recordset.RecordCount Then
            Screen.ActiveForm.CmdNext.Enabled = False
        Else
            Screen.ActiveForm.CmdNext.Enabled = True
        End If
      
    End Function

  13. #13
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    What does that have to do with form caption that you started out with?
    I'm afraid that without knowing if there's another thread on this topic posted by you (as alluded to in post 10) I'm going to have to sit this one out.

    However, since the last question seems unrelated to this thread, I'll say "it depends". There is no single answer to this because of the many design possibilities.
    If there is or will only ever be 1 or 2 forms with custom record navigation, easier to keep it local IMHO. If not, I would pass the form or form name to a procedure. I get the impression that you think it has to be a function since that's all that has been shown or mentioned here, yet you are not using the function to return a value. As long as you're not planning to call the procedure from a toolbar, ribbon or query and it isn't returning anything, it can be a sub.

  14. #14
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,655
    What I suspect as the reason for this procedure is to bypass the error when trying to navigate previous on the first record or navigate next on the last record.
    This is usually pretty easy to handle with error handling.

  15. #15
    d9pierce1 is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    I took some time this weekend and was able to look over some of the materials in detail. I just want to thank you all for your help and I got some good things out of this. Have also decided not to use the public function on the buttons and such. Again, thanks to all of you.
    Dave

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

Similar Threads

  1. Replies: 1
    Last Post: 08-06-2018, 10:57 AM
  2. Best screen resultion for most common screen sizes
    By sjs94704 in forum Database Design
    Replies: 3
    Last Post: 05-26-2015, 06:12 AM
  3. Replies: 21
    Last Post: 01-21-2014, 05:04 PM
  4. Replies: 1
    Last Post: 01-11-2014, 12:39 PM
  5. Replies: 11
    Last Post: 06-05-2011, 09:51 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