Results 1 to 14 of 14

Thread: Help

  1. #1
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Unanswered: Help

    I have about 10 text fields on my form, of the fields, I have an "CustNo" field. I wanted my users to be able to type in the "CustNo" and then by hittiing enter, have the matching records displayed in form view.

    CustNo is not the Primary Key........CustID is PrimaryKey but its invisible in form.


    Any assistance would be greatly appreciated!
    Skharva

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    I'm assuming that you want the records to be displayed within the same Form (continuous or not, it doesn't matter)

    In the On Open and the On Close events of your Form place this line of code:
    Code:
       Me.Filter = ""
    Now.....because you want the ENTER key to play a role here Place the folloing code into the On KeyDown event of the CustNo TextBox field
    Code:
    'Use below If the CustNo data type is numeric (Number).
     If KeyCode = 13 Then
        Me.Filter = "[myTable'sCustomerNumberFieldName] = " & clng(Me.CustNo.Text )
        Me.FilterOn = True
        Me.Requery
        KeyCode = 0
     End If
    OR

    Code:
    'Use below If the CustNo data type is String (Text).
     If KeyCode = 13 Then
        Me.Filter = "[myTable'sCustomerNumberFieldName] = '" & cstr(Me.CustNo.Text) & "'"
        Me.FilterOn = True
        Me.Requery
        KeyCode = 0
     End If
    OR

    Now only the records pertaining to your supplied Customer Number will be displayed.


  3. #3
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by CyberLynx
    I'm assuming that you want the records to be displayed within the same Form (continuous or not, it doesn't matter)

    In the On Open and the On Close events of your Form place this line of code:
    Code:
       Me.Filter = ""
    Now.....because you want the ENTER key to play a role here Place the folloing code into the On KeyDown event of the CustNo TextBox field
    Code:
    'Use below If the CustNo data type is numeric (Number).
     If KeyCode = 13 Then
        Me.Filter = "[myTable'sCustomerNumberFieldName] = " & clng(Me.CustNo.Text )
        Me.FilterOn = True
        Me.Requery
        KeyCode = 0
     End If
    OR

    Code:
    'Use below If the CustNo data type is String (Text).
     If KeyCode = 13 Then
        Me.Filter = "[myTable'sCustomerNumberFieldName] = '" & cstr(Me.CustNo.Text) & "'"
        Me.FilterOn = True
        Me.Requery
        KeyCode = 0
     End If
    OR

    Now only the records pertaining to your supplied Customer Number will be displayed.


    What do you mean by "myTable'sCustomerNumberFieldName" ? Are you talking about just field name or table name and then field name ?
    Skharva

  4. #4
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    If I am not mistaken I think he just means the Field name.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  5. #5
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by JSThePatriot
    If I am not mistaken I think he just means the Field name.

    JS
    I try putting both table name and field name & also just field name it self but it gave me error "can't assign value to this object "
    Skharva

  6. #6
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    You may want to try...

    Code:
    [Tables]![yourtablename]![yourfieldname]
    I havent ever had anything like that... I do have another way to have that solved but the method stated above is much more friendly.

    (I use a query that looks on my form's textbox value for a parameter.)

    Hope I can help,
    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  7. #7
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by JSThePatriot
    You may want to try...

    Code:
    [Tables]![yourtablename]![yourfieldname]
    I havent ever had anything like that... I do have another way to have that solved but the method stated above is much more friendly.

    (I use a query that looks on my form's textbox value for a parameter.)

    Hope I can help,
    JS
    Still i'm getting error. Do you have any sample database where i can see this as an example ?
    Skharva

  8. #8
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Okay... Are you wanting an example of how I have done it in the past or are you asking for a working example of the above?

    I dont have anything from above which is why I cant help much :-/. I wish I could help more. I do have an example of my way of doing it. (Though I do plan on trying that alternative way at somepoint soon.)

    Basically what you are wanting is a search box right? Where they can type in a value press a button an viola they get a form or spreadsheet of data that only looks at that specific entered information, Right?

    I hope I can help,
    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  9. #9
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by JSThePatriot
    Okay... Are you wanting an example of how I have done it in the past or are you asking for a working example of the above?

    I dont have anything from above which is why I cant help much :-/. I wish I could help more. I do have an example of my way of doing it. (Though I do plan on trying that alternative way at somepoint soon.)

    Basically what you are wanting is a search box right? Where they can type in a value press a button an viola they get a form or spreadsheet of data that only looks at that specific entered information, Right?

    I hope I can help,
    JS
    Can i see the example of the way you did it in the past, If its not a problem ?

    Thanks
    Skharva

  10. #10
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Not a problem at all... please check back in about 3 mins for the example data. I have to get it together. I hope it will help you in your situation.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  11. #11
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557

    Workgroup Troubles... hold on still working on it

    I am having some workgroup troubles. Everytime I create a new database it keeps asking me to enter my password for my secured database, I think I need to run a repair... hold on I will get you an example as fast as possible.


    Thanks for your patience,
    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  12. #12
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Re: Workgroup Troubles... hold on still working on it

    Originally posted by JSThePatriot
    I am having some workgroup troubles. Everytime I create a new database it keeps asking me to enter my password for my secured database, I think I need to run a repair... hold on I will get you an example as fast as possible.


    Thanks for your patience,
    JS
    I'm not in hurry so take your time and i really appreciate for doing this. Thanks
    Skharva

  13. #13
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557

    Okay...

    Okay here it is.

    The Find form is the form that runs everything.

    The Parts table is all the data (except the tools option from the find form. the tools table is too large).

    The rest of the forms are so I can view the data that is found.

    The queries you will want to look at in design view.

    Also pressing Alt + F11 will show you my source code for the two forms that have some.

    I hope this will help you in your quest... click the following link, it will take you to another post of where I am trying to find a better way of doing this form find stuff. (I am currently working on a list box selection method.) Havent finished yet but will keep posting updates in that link as I make them .

    http://www.dbforums.com/showthread.php?threadid=993021

    Hope I have helped in some way,
    JS
    Attached Files Attached Files
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  14. #14
    Join Date
    Nov 2003
    Posts
    1,487
    Originally posted by Skharva
    What do you mean by "myTable'sCustomerNumberFieldName" ? Are you talking about just field name or table name and then field name ?
    To begin with, you need to be sure that the name of your table is placed into the Record Source property of your form.

    myTable'sCustomerNumberFieldName is the actual Field name within the table you had placed into the Record Source property. Everything is to be dependant from the supplied Customer Number therefore I need to assume of course that the CustNo field resides in both your Table and your Form. If this is indeed the case then the code will look like this:
    Code:
    Private Sub SrchCustNo_KeyDown(KeyCode As Integer, Shift As Integer)
    'Use below If the CustNo data type is numeric (Number).
        If KeyCode = 13 Then
           Me.Filter = "[CodeNo] = " & CLng(Me.SrchCustNo.Text )
           Me.FilterOn = True
           Me.Requery
           KeyCode = 0
        End If
    End Sub
    OR
    Code:
    Private Sub SrchCustNo_KeyDown(KeyCode As Integer, Shift As Integer)
    'Use below If the CustNo data type is String (Text).
        If KeyCode = 13 Then
           Me.Filter = "[CustNo] = '" & CStr(Me.SrchCustNo.Text) & "'"
           Me.FilterOn = True
           Me.Requery
           KeyCode = 0
     End If
    End Sub
    This is important:
    You will also need to make sure that the TextBox the user is entering the customer number into is not bound (Unbound) to the table. Add a TextBox to the top of your form and name it SrchCustNo. In the Label for the TextBox, make it read "Search For Customer" or something like that. Then use the code above.


Posting Permissions

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