To search record

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

    #91
    Quote added retrospectively from memory as the original contents of post #90 have been completely replaced.
    Originally posted by puT3 (paraphrased)
    Yes, I fixed the SQL from tS.SubjectID to tS.[Topical Headings]...
    We may be nearly there now, but making changes without telling me is the sort of thing which may still throw a spanner in the works.

    I can't make intelligent decisions without correct information.

    Did you see the other question? Were any other changes made?
    If so, my earlier post may not work very well for you (although it should give you an example to work from at least).

    Comment

    • puT3
      New Member
      • Jul 2008
      • 145

      #92
      I am trying urs code right now...Ill get it back to u

      Comment

      • puT3
        New Member
        • Jul 2008
        • 145

        #93
        Code:
          [B]'%[/B]F ==> Field to search on
          [B]'%[/B]E ==> Equality operator
          [B]'%V[/B] ==> Value (to search for)
        What is these mean?
        Do I need to write these one?
        Code:
         ==> Field to search on
         ==> Equality operator
         ==> Value (to search for)
        sorry I understan it now

        Comment

        • puT3
          New Member
          • Jul 2008
          • 145

          #94
          Code:
            Case 1
              strField = "Title"
            Case 2
              strField = "Author Name"
            Case 3
              strField = "Publication Name"
            Case 4
              strField = "CallNumber"
            Case 5
              strField = "Topical Headings"
            Case 6
              strField = "ISBN/ISSN"
          I dont understand this,is it the (Title,Author Name, Publication Name,CallNumber ,Topical Headings and ISBN/ISSN) are from the query/table?

          Why are OptTitle,OptPub lication..... are not used?
          Code:
          strwhere = [B] Replace[/B] (strWhere,'%F",strField)
          and what is the Replace function?

          Another thing,I forgot 2 ask u, in this code
          Code:
          Select Case Me.[Search By]
          Is it the name of the option group frame?

          tq again

          Comment

          • puT3
            New Member
            • Jul 2008
            • 145

            #95
            I try this code from ur post
            Code:
            DoCmd.OpenForm(FormName:="[Printing Media Library]", WhereCondition:=strWhere, DataMode:=acFormReadOnly)
            but I get an error said "Expected:= "

            No other changes are made except for OptPhrase where I exclude it and delete it from the form...does it affect anything if I delete it?

            Is this form for read only because i see the data mode is read only?
            It shows result line by line right?

            Do u remember from before I said that I want to have a checkbox in the form so that user can view the complete details of the search material in another form?

            because I want the filtered form only shows partial of information for example,
            if user click on author, in the filtered form i want it to show the author name,title,year ,and ISBN number and have a checkbox next to it,so that the user will click it and another form that have full details will appear....

            sorry if this will change the coding,i just want to tell u in case u forget about it....

            Comment

            • puT3
              New Member
              • Jul 2008
              • 145

              #96
              (1) I already ur code, at first it seem to be running eventhough a message box appear
              (2) However,the next time I try it,nothing happen when I click the Search button...what is the problem?Is it the code? I do not change anything except I change the name of the button (cmdSearch) and the text box(txtFind) to match the name in the code

              I try to make a new form but it still doesnt work...Any detail that u want cuz im not sure what detail it is cuz there is no error message for (2)

              Comment

              • puT3
                New Member
                • Jul 2008
                • 145

                #97
                I fixed the error but the code do not open the [Printing Media Library] form instead a Find and Replace box appear

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32666

                  #98
                  Originally posted by puT3
                  In
                  Code:
                  Select Case Me.[Search By]
                     Case 4
                  It is for OptPhrase,I think I will skip this one,im not going to use it...you can ignore this...
                  Thank you for this info.

                  To effect this simply remove lines #31 & #32 from the code in post #89.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32666

                    #99
                    Originally posted by puT3
                    Code:
                    Case 1
                      strField = "Title"
                    Case 2
                      strField = "Author Name"
                    Case 3
                      strField = "Publication Name"
                    Case 4
                      strField = "CallNumber"
                    Case 5
                      strField = "Topical Headings"
                    Case 6
                      strField = "ISBN/ISSN"
                    I dont understand this,is it the (Title,Author Name, Publication Name,CallNumber ,Topical Headings and ISBN/ISSN) are from the query/table?

                    Why are OptTitle,OptPub lication..... are not used?
                    ...
                    This is because when an option control is selected within an Option Group, the value of the Option Group itself reflects which of its option controls is currently selected. As there is only one that can be selected at any time, this is quite logical and makes for easier checking. It is also possible to check the vlaues of the option controls themselves.
                    Originally posted by puT3
                    ...
                    Code:
                    strWhere = [B]Replace[/B](strWhere,'%F",strField)
                    and what is the Replace function?
                    ...
                    I suggest you find the Help on this for a full explanation. Essentially though, it replaces all occurrences of the second parameter, where found in the first parameter, with the third parameter.
                    Code:
                    Debug.Print Replace("ABCDEFG", "C", "_")
                    AB_DEFG
                    Originally posted by puT3
                    ...
                    Another thing,I forgot 2 ask u, in this code
                    Code:
                    Select Case Me.[Search By]
                    Is it the name of the option group frame?

                    tq again
                    Yes :)

                    See earlier explanation of your Select Case question.

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32666

                      Originally posted by puT3
                      I try this code from ur post
                      Code:
                      DoCmd.OpenForm(FormName:="[Printing Media Library]", WhereCondition:=strWhere, DataMode:=acFormReadOnly)
                      but I get an error said "Expected:= "

                      No other changes are made except for OptPhrase where I exclude it and delete it from the form...does it affect anything if I delete it?
                      ...
                      The code you have posted cannot run as you have posted it. You say you have made no changes to the code, yet I can immediately see that the first word of my original code on the line (Call) is missing and that you have merged the line into one from three.

                      Now, call me picky if you will, but I have 101 examples, in this thread, of where you've changed things you don't fully understand, without telling me what you've changed, and I've had to work out what's gone wrong.

                      So, for this, I want to see where my original code went wrong.

                      Removing OptPhrase should not cause any problems for the code as posted.
                      Originally posted by puT3
                      ...
                      Is this form for read only because I see the data mode is read only?
                      It shows result line by line right?
                      ...
                      I expect it will be read only. The query it's bound to will probably make it read only. I'm not sure what you mean when you say "I see the data mode is read only?" though. Where?

                      If it shows results line by line, then this is how you've designed your form. We have not discussed how this should be done as it doesn't effect what we're doing very directly. Certainly showing the results in DataSheet mode should not cause any problems.
                      Originally posted by puT3
                      ...
                      Do u remember from before I said that I want to have a checkbox in the form so that user can view the complete details of the search material in another form?

                      because I want the filtered form only shows partial of information for example,
                      if user click on author, in the filtered form i want it to show the author name,title,year ,and ISBN number and have a checkbox next to it,so that the user will click it and another form that have full details will appear....

                      sorry if this will change the coding,i just want to tell u in case u forget about it....
                      I don't remember that, but it's not important. You've mentioned it again now.

                      This is not something we should be looking at immediately. I assume you want the further detail to be shown from something found on the [Printing Media Library] form.

                      We're principally looking at the code on the [Search Form] for now. I don't think adding this functionality later to the [Printing Media Library] form will be a problem. It shouldn't effect what we're doing now.

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32666

                        Originally posted by puT3
                        (1) I already ur code, at first it seem to be running eventhough a message box appear
                        (2) However,the next time I try it,nothing happen when I click the Search button...what is the problem?Is it the code? I do not change anything except I change the name of the button (cmdSearch) and the text box(txtFind) to match the name in the code

                        I try to make a new form but it still doesnt work...Any detail that u want cuz im not sure what detail it is cuz there is no error message for (2)
                        Originally posted by puT3
                        I fixed the error but the code do not open the [Printing Media Library] form instead a Find and Replace box appear
                        What I suggest you do at this point, bearing in mind the other question relating to the code as well, is to post in (copy/paste please) the code you are actually using, then expain as simply and clearly as possible, what is going wrong AT THIS TIME (to match the code posted).

                        If you can include both of these in a single post I will have something I can refer to and work from in one place.

                        Comment

                        • puT3
                          New Member
                          • Jul 2008
                          • 145

                          This is the code
                          Code:
                          Private Sub cmdSearch_Click()
                          
                          Dim strWhere As String, strField As String
                          
                          '%F ==> Field to search on
                          '%E ==> Equality operator
                          '%V ==> Value (to search for)
                          
                          strWhere = "[%F] Like '%V'"
                          
                          Select Case Me.[Search Type]
                          
                              Case 1
                                  strField = "Title"
                              Case 2
                                  strField = "Author Name"
                              Case 3
                                  strField = "Publication Name"
                              Case 4
                                  strField = "CallNumber"
                              Case 5
                                  strField = "Topical Headings"
                              Case 6
                                  strField = "ISBN/ISSN"
                          End Select
                          
                          strWhere = Replace(strWhere, "%F", strField)
                          
                          Select Case Me.[Search By]
                          
                              Case 1
                                  strWhere = Replace(strWhere, "%V", "*" & Me.txtFind & "*")
                              Case 2
                                  strWhere = Replace(strWhere, "%V", Me.txtFind)
                                  strWhere = Replace(strWhere, "Like", "=")
                              Case 3
                                  strWhere = Replace(strWhere, "%V", Me.txtFind & "*")
                          End Select
                          
                          DoCmd.OpenForm "Printing Media Library", , , strWhere, acFormReadOnly
                          
                          End Sub
                          When I click the button,a Office Find and Replace box appear

                          Comment

                          • NeoPa
                            Recognized Expert Moderator MVP
                            • Oct 2006
                            • 32666

                            OK. Nothing obvious there.
                            1. Does it happen this way for every Option you select, or are there some combinations that work ok?
                            2. Please add the following line after line #38 of your posted code anyway. Whenever you report on this error after this you can include the results of this line with the report so I know what's been selected :
                              Code:
                              Debug.Print strWhere

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32666

                              While you're about it, can you dump in the SQL of the query you have the form ([Printing Media Library]) bound to (and its name).

                              I will reformat it for you don't worry. Just dump it in.

                              Comment

                              • puT3
                                New Member
                                • Jul 2008
                                • 145

                                Originally posted by NeoPa
                                While you're about it, can you dump in the SQL of the query you have the form ([Printing Media Library]) bound to (and its name).

                                I will reformat it for you don't worry. Just dump it in.
                                Sorry,I dont understand do u mean to discard it, discard it from the RecordSource of the search form or just discard the SQL in the query?

                                Comment

                                Working...