Search Button Code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GoodGirl
    New Member
    • May 2009
    • 9

    #16
    Neopa & ChipR :

    4- I choose the lower case.

    When I put my 5th line as Else statement without End If, it shows a compile error [Else without If], when I put ElseIf, it shows syntax error (without any other clarification) and shows [ElseIf] statement with red line.

    Neopa : your code in participation #14 didn't work!! , I still click on the search button without any response or even error message.

    I wrote this code and shows to me (after entered the name) : [ Wrong name] which means it didn't make any comparison, what I should add?
    Code:
    Private Sub searchButton_Click()
    Dim Inn As String
    Inn = InputBox("Would you enter the Employee's First Name?")
    If Inn = txtFirstName Then MsgBox ("OK")
    If Inn <> txtFirstName Then MsgBox ("Wrong Name")
    End Sub
    Neopa: I think I have a compilation problem (based on your explanation) because after I checked (Require variable compilation), nothing changed and [Option Explicit] didn't show in the code.

    -Every time I post or take any code, I compile and run it before write or do anything.


    Thanks guys.
    Last edited by NeoPa; May 18 '09, 12:56 PM. Reason: Please use the [CODE] tags provided.

    Comment

    • GoodGirl
      New Member
      • May 2009
      • 9

      #17
      I'm waiting anybody answer.

      Comment

      • Stewart Ross
        Recognized Expert Moderator Specialist
        • Feb 2008
        • 2545

        #18
        I suspect you will need to rethink what you are doing in this one. Aside from your IF statements still being unsoundly written (even after what has posted above to help you) it is not possible for us to know what the source for your txtfirstname variable which you are comparing the input to should be.

        You were asked by NeoPa in post # 5 to give us more information on which we can help you, but as yet you have not responded to the detail of that request (what you put into post 6 does not give us enough detail to know how you are intending to compare values at all).

        Sorry, but I cannot see how we can help you when you have not given us anything to work on other than a somewhat redundant pair of IF statements which are not the true source of your problem.

        -Stewart

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32662

          #19
          Originally posted by GoodGirl
          Neopa : your code in participation #14 didn't work!! , I still click on the search button without any response or even error message.
          Did you change the code to reflect your actual control name. I copied SearchButtonl_C lick from ADezii's post. That would explain why nothing happened.
          Originally posted by GoodGirl
          NeoPa: I think I have a compilation problem (based on your explanation) because after I checked (Require variable compilation), nothing changed and [Option Explicit] didn't show in the code.
          Option Explicit will appear for every module created after that is set. I'm afraid it doesn't change any existing modules, but is definitely a good idea to have it set. That way you will never experience the problems associated with this in any future projects.

          For existing modules, simply type or paste in a line :
          Code:
          Option Explicit
          Originally posted by GoodGirl
          -Every time I post or take any code, I compile and run it before write or do anything.
          That's great. I wish everyone were as clever.

          Comment

          • GoodGirl
            New Member
            • May 2009
            • 9

            #20
            Nice NeoPa:
            I post [Option Explicit] and finally it worked with me
            I put this code to ensure the simplest level of comparison:
            Code:
            Option Explicit
            Private Sub searchButton_Click()
            Dim Inn As String
            Inn = InputBox("Would you enter the Employee's First Name?")
            If Inn = "amin" Then MsgBox ("OK")
            If Inn <> "amin" Then MsgBox ("Wrong Name")
            End Sub
            It worked very well, when I entered “amin” it shows OK, When I entered any name other than “amin” it shows to me “Wrong Name”.
            So, now I want to create a variable which holds values of FirstName column ,then I can enter this variable into a comparison with [Inn].
            After that , I want to select all the information related the FirstName and show it in a message box (in case of true name).
            stewart-ross-inverness:

            Thanks for contribution , you are right maybe not all details are clear (I’m sorry for that) , but I’m writing as much as I can understand.

            I appreciate you guys .
            Last edited by NeoPa; Jun 4 '09, 12:41 PM. Reason: Please use the [CODE] tags provided.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32662

              #21
              Right then.

              We need to start with the table you're planning on keeping the name data in. What are the details (meta-data)?

              META-DATA
              This will work best if you can post the meta-data (info about the layout / structure) of the table in the same way as I use in my example. Click on the Reply button and you will have access to all the codes I've used. PK & FK stand for Primary Key & Foreign Key respectively. Never use TABs in this as the layout gets mucked up. Use spaces and all is fine.
              Table Name=[tblStudent]
              Code:
              [I]Field           Type      IndexInfo[/I]
              StudentID       AutoNumber    PK
              Family          String        FK
              Name            String
              University      String        FK
              Mark            Numeric
              LastAttendance  Date/Time

              Comment

              • GoodGirl
                New Member
                • May 2009
                • 9

                #22
                Nice NeoPa , but I didn't get the point?
                what's the relation between the code required for the button and what you said?

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32662

                  #23
                  The code will need to refer to the items.

                  When I get to think about what needs to be in the code I will need to have an understanding of what I'm working with.

                  Comment

                  Working...