Display single record or duplicate records

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

    #46
    I'm with Twinny on this. It looks very much like your Event Procedure is not set to be called for the appropriate event. A quick way to fix this, assuming the name of the Event Procedure is correct and matches the name of the Control, is to Cut and Paste all the code from the module. The act of Pasting it back in causes Access to assign the correct properties automatically for validly designed and named Event Procedures.

    You can test if it's properly set by putting a breakpoint (See Debugging in VBA.) on the line after the Debug.Print line.

    Also, though it shouldn't make too much difference, your Immediate Pane is scrolled off to the right when you took the last picture so would miss the start of any text printed there. As Twinny says, copy the contents instead.

    Comment

    • mcervenka1
      New Member
      • Apr 2018
      • 37

      #47
      oK. I deleted and created a new UPDATE RECORD form. I copies all VBA from previous form into new form and made applicable changes for the titles of the new command buttons....ie.. Private Sub Command 445 Click() and Filter Text 438. (See below). When I open the form and enter valid receipt number the form does not respond. When I go to design view and press RUN/RunSubform, I receive a MACRO box
      asking for MACRO NAME. When I run DEBUG, I receive no errors. I ran the Cntrl G and it only displayed the word "Immediate" with nothing below it


      Code:
      Option Compare Database
      Option Explicit
      
      Private Sub txtSearch_AfterUpdate()
      On Error GoTo EH
          Dim strFilter As String
          
          With Me
               strFilter = "([ReceiptNumber] Like '*%RS*') OR " _
                        & "([ANumber] Like '*%RS*') OR " _
                        & "([SerialNumber] Like '*%RS*')"
               .Filter = Replace(strFilter, "%RS", .Text438)
               .FilterOn = True
          Debug.Print .Filter;
          End With
          Exit Sub
          
      EH:
          MsgBox "There was an error filtering the Form!" _
               & vbCrLf & vbCrLf _
               & Err.Number & vbCrLf _
               & Err.Description & vbCrLf & vbCrLf _
               & "Please contact your Database Administrator" _
               , vbCritical _
               , "WARNING!"
          Exit Sub
      End Sub
      Private Sub Command445_Click()
      
      End Sub
      Last edited by twinnyfo; Jun 14 '18, 05:07 PM. Reason: added code tags

      Comment

      • twinnyfo
        Recognized Expert Moderator Specialist
        • Nov 2011
        • 3653

        #48
        Is your Text Box properly named txtSearch and when you look at the properties for that control, does it have [Event Procedure] listed in the "On Click" Event?

        Comment

        • mcervenka1
          New Member
          • Apr 2018
          • 37

          #49
          for the command button labeled "Search" and contains VBA above:
          Name - Command445
          Caption - Search
          On Click - event procedures

          For Text box where Receipt Number or ANumber or Serial Number is entered:
          Name - Text438
          Caption - empty
          On Click - empty no event procedures

          For list box command button:
          Name - Label439
          Caption - 438
          Event - shows nothing

          Comment

          • twinnyfo
            Recognized Expert Moderator Specialist
            • Nov 2011
            • 3653

            #50
            So, if you look closely at the cod eyou posted in Post #47, the name of the Procedure is txtSearch_After Update. This means that the code is looking for a Text box with the name of txtSearch, and when someone enters data into that text box and hits Enter or Tab, the Text Box is then "updated" and this code will fire.

            No real need for a "Search button" as your code should execute without it.

            Comment

            • mcervenka1
              New Member
              • Apr 2018
              • 37

              #51
              So if I remove the search button, what should the VBA read after "Private Sub"? Should I delete "txtSearch_Afte rUpdate()". If so, what should I replace with in order to complete the Private Sub or does the Private sub start above "On Error GoTo EH"

              Comment

              • twinnyfo
                Recognized Expert Moderator Specialist
                • Nov 2011
                • 3653

                #52
                Rename your Text Box to txtSearch. That is a start.

                Comment

                • mcervenka1
                  New Member
                  • Apr 2018
                  • 37

                  #53
                  For Text box where Receipt Number or ANumber or Serial Number is entered:
                  Name - Text438
                  Caption - empty
                  On Click - empty no event procedures

                  YOu want me to change Name from - Text438 to txtSearch?

                  Comment

                  • twinnyfo
                    Recognized Expert Moderator Specialist
                    • Nov 2011
                    • 3653

                    #54
                    Yes. OR you can change the name of the procedure. It doesn't matter. But that is how the procedure knows which control it is connected to.

                    Comment

                    • mcervenka1
                      New Member
                      • Apr 2018
                      • 37

                      #55
                      Ok.. I have changed the name of the unbound textbox to txtsearch. Enter receipt number and still just sits there. You said earlier that I did not need the SEARCH command button. Should I still remove the button? What about the VBA code?

                      Comment

                      • mcervenka1
                        New Member
                        • Apr 2018
                        • 37

                        #56
                        please see attachment when I debug.
                        Attached Files

                        Comment

                        • twinnyfo
                          Recognized Expert Moderator Specialist
                          • Nov 2011
                          • 3653

                          #57
                          check to make sure that the After Update Event in the Text Box has [Event Procedure] in it. If not, click the drop down of that field and select Event Procedure.

                          Comment

                          • mcervenka1
                            New Member
                            • Apr 2018
                            • 37

                            #58
                            ok... Event Procedure is there now. Still no search performed. Earlier was told do not really need search button. I am using the search button with no results. Should I delete search button, if so, what about the related VBA coding

                            Comment

                            • mcervenka1
                              New Member
                              • Apr 2018
                              • 37

                              #59
                              Hello. The link I have provided is to the site where I originally got the guidance for my Update Record search by list box. I do not know if it is helpful in my situation, since so much has changed with VBA. https://www.youtube.com/watch?v=wCPs4aE5I2w

                              Thank You

                              Comment

                              • twinnyfo
                                Recognized Expert Moderator Specialist
                                • Nov 2011
                                • 3653

                                #60
                                Before we continue with this, do you understand the nature of procedures and controls? A control is linked to a procedure based upon the name of the control and the name of the procedure, as well as the event that fires the procedure. When you have a control and go to its properties, and select “Event Procedure” from the drop down, it will automatically take you to the VBA module that should hold that procedure. In your case, it should take you to the procedure you have created. If not, it should create a new event procedure.

                                For example, take your text box txtSearch. In the properties, find the After Update event. Go to the drop down and select [Event Procedure]. It should take you to the VBA procedure we have written called txtSearch_After Update.

                                Let me know what happens.

                                Comment

                                Working...