Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002

    Unanswered: Changing a Caption and properties

    Hi there,

    I have a form called usysbfClientCaseNotesView
    A label in the form header called [Label42] which has the caption: "VIEW PREVIOUS CLIENT CASENOTE DETAILS"
    I have a text box called [changeform] in the details section of the form.

    I want to open a form 'usysbfClientCaseNotesView' with the properties

    ALLOW EDITS = NO if a textbox [changeform] on the form equals "" (NULL)
    ALLOW EDITS = YES if a textbox [changeform] on the form equals "change"

    I will also need to change the [Label42] caption to: "VIEW PREVIOUS CLIENT CASENOTE DETAILS" if the textbox [changeform] is "" (null)
    change the [Label42] caption to: "CHANGE CLIENT CASENOTE DETAILS" if the textbox [changeform] is "change"

    I have spent hours on this and cannot seem to get it to work.
    I can't even seem to get the label to change.

    '''''''''''''Test to see if form should open as a allow edits or not allow edits
    If (Me![changeform].Value = "change") Then Me.[Label42].Caption = "CHANGE CLIENT CASENOTE DETAILS"

    Can you help me with the code to do this?
    Can you also advise which property is best to use ie on_open or something else?

    Thanks heaps in advance for any help given.
    Last edited by Karen Day; 07-05-12 at 06:24. Reason: error in writing heading and body of text

  2. #2
    Join Date
    May 2004
    New York State
    Hi, Karen,

    To make things a bit easier, why not change the textbox changeform to a combobox with the two possible values "View" and "Change." In the OpenForm method, pass the value ("View" or "Change") as an OpenArgs property. In the new form's OnOpen event, the first thing you should do is to read the value (Me.OpenArgs) and set the values of the label42 and AllowEdits there.


  3. #3
    Join Date
    May 2002
    Hi all,

    For some unknown reason I could not run my code from within the form. I had to run it from another form [ClientCaseNotesPrintForm] (which was ok because the [ClientCaseNotesPrintForm] held a button which opened the form called usysbfClientCaseNotesView)

    So the following ened up working perfectly. May be a bit clunky but it works.

    Private Sub ViewCaseNotesBtn_Click()
    On Error GoTo Err_ViewCaseNotesBtn_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "usysbfClientCaseNotesView"

    stLinkCriteria = "[ClientID]=" & Me![ClientID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    'switch back to ClientCaseNotesPrintForm
    DoCmd.Close 'close ClientCaseNotesPrintForm
    Forms!usysbfClientCaseNotesView.SetFocus 'make sure this form is showing

    Forms!usysbfClientCaseNotesView.[changeform].Value = "Change"
    If (Forms!usysbfClientCaseNotesView.[changeform].Value = "Change") Then
    Forms!usysbfClientCaseNotesView.Label42.Caption = "CHANGE CLIENT CASENOTE DETAILS"
    End If

    'If CHANGE has been selected then allow EDITS to occur
    If Forms!usysbfClientCaseNotesView.[changeform].Value = "Change" Then

    With Forms!usysbfClientCaseNotesView
    .AllowEdits = True
    .AllowAdditions = False
    .AllowDeletions = False
    End With

    With Forms!usysbfClientCaseNotesView
    .AllowAdditions = False
    .AllowDeletions = False
    .AllowEdits = False
    End With

    End If

    Exit Sub

    MsgBox Err.Description
    Resume Exit_ViewCaseNotesBtn_Click

    End Sub

Posting Permissions

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