Like Filter in Query Based Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #16
    Originally posted by DJRhino1175
    DJRhino1175:
    The only thing I don't understand is what do you mean by YourNewFlag?
    My apologies. I was called away so didn't spend the usual amount of time checking carefully over what I'd written before I posted it :-( Your amendment is absolutely spot on :-)

    Do I know what you have in [Close Reject Tag Form]? Whatever the answer I suspect you're on the right lines. It should look something like :
    Code:
    SELECT   [Reject Tag Number]
           , [Selected]
    FROM     [Reject Tags]
    WHERE    Not ([CANCEL Or [Closed])
    ORDER BY [Reject Tag Number]
    Still to post the rest later this evening, though there may not be too much left now.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32656

      #17
      Hi DJ.

      The code to open the new Form (frmSelRTNo) would go something like what I show below. I'll leave you to add the Dim lines as they should be straightforward , but notice dbCurDb should be done as DAO.Database.
      Code:
      Set dbCurDb = CurrentDb()
      'Before we open the Form we must clear the data.
      strSQL = "UPDATE [Reject Tags] Set [Selected]=False"
      Call dbCurDb.Execute(strSQL, DbFailOnError)
      'Notice we open as Dialog so the following code is triggered
      ' only after it's closed.
      Call DoCmd.OpenForm(FormName:="frmSelRTNo", WindowMode:=acDialog)
      ...
      'Open up your old Form here which is filtered as discussed earlier.
      ...
      'Clear the [Selected] data again.
      Call dbCurDb.Execute(strSQL, DbFailOnError)

      Comment

      • DJRhino1175
        New Member
        • Aug 2017
        • 221

        #18
        Not sure if I missed something. It runs the code just fine. It opens the dialog form. I'm able to select multiple tags by checking the yes/no box, but when I close this form, it opens the correct form but it isn't filtered. I get no error messages. Here is the code as I have it currently:

        Code:
        Private Sub Disposition_Close_Reject_Tag_Click()
        
        Dim dbsCurrent As Database
        Set dbsCurrent = CurrentDb
        Dim strsql As String
        
        On Error GoTo Close_Err
        
            'Before we open the Form we must clear the data.
            strsql = "UPDATE [Reject Tags] Set [Selected]=False"
            Call dbsCurrent.Execute(strsql, dbFailOnError)
            'Notice we open as Dialog so the following code is triggered
            ' only after it's closed.
            Call DoCmd.OpenForm(FormName:="frmSelRTNo", WindowMode:=acDialog)
            Call DoCmd.OpenForm(FormName:="Close Reject Tag Form")
        
        
        Close_Exit:
            Exit Sub
        
        Close_Err:
            MsgBox Error$
            Resume Close_Exit
            
        'Clear the [Selected] data again.
        Call dbsCurrent.Execute(strsql, dbFailOnError)
        
        End Sub

        Comment

        • DJRhino1175
          New Member
          • Aug 2017
          • 221

          #19
          Neopa,

          I was able to get it. I had "frmSelRTNo " set up incorrectly and didn't have [Select] set up right in the query for the close form. Tried it 3 or 4 times and it worked every time. Worked like a charm. Thanks for your assistance.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32656

            #20
            Hi DJ.

            Very pleased to hear you managed to get it working, and you're very welcome to the asistance :-)

            I had to reset your selection for Best Answer as we very rarely award that to the person asking the question (for what should be obvious reasons) and it also has to be something that someone new coming to the question would find most illuminating or illustrative. I'm sure you were simply trying to express that you were happy with the result - and that we do appreciate.

            Having looked at your code I would recommend that you make consistent use of mixed case in the naming of your variables. The usability of strsql & strSQL are some distance apart. I'll leave you with that parting idea.

            Comment

            Working...