Results 1 to 9 of 9
  1. #1
    Lounger
    Join Date
    Mar 2010
    Location
    UK
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Good Morning loungers!

    Im using access 2003 to be the front end for a dataloader. basically this form passes in parameters to a table for a stored procedure on a SQL box to pick up and use.

    We have since complicated the whole process but only allowing certain groups of data to be used (as this is a hospital its things like Admited patients non-admited etc)

    a small design option brought back to me by my end user is that the tick box that says "Select all" on one of these forms always says Select all... to me this is not a problem as i see it in the following way, you are either saying yes to select all, or no, hense the true false.

    but, as im not the end user and its my job to make them happy, i am doing as im told. But, ive hit a few snags.

    I cant edit an object on a form while the form is not in design view.

    My code is probably the "Round the houses" way of achieving my goal, but as you all may have worked out by now, im pretty new to this game.

    So, as i cant edit the object i close the form, re open it in design mode, and then aim to change the object, but, i cant reffer to it in the same way, so, how would i refer to an object in design mode?

    would i be treating this as i would if i were refferencing an object on anpother form?

    Below is my code,


    Private Sub chkSelectAll_AfterUpdate()
    Dim strName As String

    If Me.chkSelectAll.Value = -1 Then
    strName = "Clear All"
    ElseIf Me.chkSelectAll.Value = 0 Then
    strName = "Select All"
    End If

    'turn off screen updates
    'Application.Echo False

    'Close For to open in design view
    DoCmd.Close acForm, "FrmLoad"
    DoCmd.OpenForm "FrmLoad", acDesign

    'Change the Caption
    Me.lbl_Toggle.Caption = strName

    'Close Design view to open normal
    DoCmd.Close acForm, "FrmLoad"
    DoCmd.OpenForm "FrmLoad", acNormal, , , acFormAdd

    'Turn on screen updates
    'Application.Echo True

    End Sub

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Quote Originally Posted by Christopher Theobald View Post
    Private Sub chkSelectAll_AfterUpdate()
    Dim strName As String

    If Me.chkSelectAll.Value = -1 Then
    strName = "Clear All"
    ElseIf Me.chkSelectAll.Value = 0 Then
    strName = "Select All"
    End If
    'Change the Caption
    Me.lbl_Toggle.Caption = strName
    End Sub
    What happens if you just change the caption at the end of the after update event?
    Regards
    John



  3. #3
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    How about an alternative suggestion:
    Change the label to a text box and change the content of the text box using code. That way you don't have to flip into design mode at all.
    Wendell

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Christopher,

    If you change it to a text box you can use the Locked & Enabled properties to control user access to the field.

    RG
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Quote Originally Posted by WendellB View Post
    Change the label to a text box and change the content of the text box using code. That way you don't have to flip into design mode at all.
    You can change the Caption of a Label (via code) without switching to Design mode. I do it regularly.
    Regards
    John



  6. #6
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Brisbane, Queensland, Australia
    Posts
    387
    Thanks
    0
    Thanked 1 Time in 1 Post
    John is correct.

    You just need to put the code to set the caption in both the after update of the checkbox and in the on current event of the form.

    The on current event will set the caption when you open the form of move to another record. In this code snippet, the label attached to the check box is named lblSelectAll

    You can also simplify your code as there are only two possible values for a check box. So the 'else if' is redundant

    Code:
    If Me.chkSelectAll.Value = True Then
      me.lblSelectAll.caption = "Uncheck to Clear All"
    Else
      me.lblSelectAll.caption = "Check to Select All"
    End If

  7. #7
    Lounger
    Join Date
    Mar 2010
    Location
    UK
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    i feel a bit of an idiot, turns out i was using "Name" instead of caption, which are two different things. Sorry about that.

    but should i ever need to, would there we a way of switching to design mode and back again?

  8. #8
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Brisbane, Queensland, Australia
    Posts
    387
    Thanks
    0
    Thanked 1 Time in 1 Post
    This will open a form and let you make a changes without the user seeing it.

    Don't know about changing to design view and back again although the openform command should change the view then you'd need to save it and use openform again with acNormal to change it back to form view.


    Code:
        DoCmd.OpenForm "frmForm", acViewDesign, , , acHidden
        'Do Stuff here
        DoCmd.Close acForm, "frmForm, acSaveYes"

  9. #9
    Lounger
    Join Date
    Mar 2010
    Location
    UK
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for your help there.

    I cant think of a situation i woud need that at the moment, but it would be handy to know! Thank you everyone!

Posting Permissions

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