• Override a form’s opening condition

    • This topic has 3 replies, 2 voices, and was last updated 14 years ago.
    Author
    Topic
    #476678

    I have a form that you normally open and then use a combobox to get the selected customer which then shows jobs in a subform.

    You can also open the job first and then hit a button to open the first form to see all the jobs by the customer. Code used is:

    Code:
        stLinkCriteria = “[AccNo]=” & “‘” & Me![cboAccNo] & “‘”
        DoCmd.OpenForm stDocName, , , stLinkCriteria

    but my users often get caught by thinking that the form is open normally and then use the combobox to try and select a new customer. The name changes but the records shown in the subform don’t. The combo code is:

    Code:
        Me.RecordsetClone.FindFirst “[AccNo] = ‘” & Me![Combo22] & “‘”
        Me.Bookmark = Me.RecordsetClone.Bookmark
        ‘Combo1.Value = “”
        If [AcconHold] = True Then
        Label47.visible = True
        Else:
        Label47.visible = False
        End If
        Me.Original_subform2!Toggle41.Value = False
        Me.Original_subform2.Form.RecordSource = “qryCustomerSublist”
        Me.Original_subform2.Requery
        Me.Original_subform2.SetFocus

    What I want is code so that if the form has been opened filtered, that using the combobox will remove the filter and correctly show the jobs.

    Please 🙂

    Viewing 2 reply threads
    Author
    Replies
    • #1279913

      Don’t know if you want something more specific than this, but at the most basic level, couldn’t you just add “If Me.FilterOn then Me.FilterOn=False” to the Combo Box code?

      I suspect you might also want to change the section of your code that sets the bookmark – which I assume is used somewhere further down the code in case you want to return to the same point? Removing the filter will effectively clear the bookmark, so you’ll need to record some other unique identifier, such as the PKF for that record, and use Find to return to it if necessary.

      Cheers

      Alison C

    • #1280118

      Thanks Alison, that does just what I want. My programming skills aren’t that great to start with and I don’t do it day to day. Its a case of “I’m pretty sure it can be done but just don’t know the specifics” but I usually understand code once I see it.

    • #1280148

      Glad it helped!

    Viewing 2 reply threads
    Reply To: Override a form’s opening condition

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: