Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Override a form's opening condition

    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
    "Heading for the deep end"

  2. #2
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Adelaide, South Australia, Australia
    Posts
    146
    Thanks
    5
    Thanked 5 Times in 5 Posts
    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

  3. The Following User Says Thank You to alifrog For This Useful Post:

    weyrman (2011-05-19)

  4. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts
    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.
    "Heading for the deep end"

  5. #4
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Adelaide, South Australia, Australia
    Posts
    146
    Thanks
    5
    Thanked 5 Times in 5 Posts
    Glad it helped!

Posting Permissions

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