Results 1 to 6 of 6

Thread: simple query using databound control

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    I need to get the case to be pulled up from what the user inputs in an input box and then query the database with that information. I cannot get it to work. I am using an msflexgrid so all cases will appear for the same person. people can be in the database by their case number more than once -- but each complaint has its own autonumber. If you follow. So the same case number say 000000 could be in the database 10 times and I want all of those to show up in the grid, but the "000000" needs to be a variable for the query!!

    here is my code i am getting a syntax error:
    Private Sub Form_Load()
    GetAuto$ = InputBox("Enter Case No", "PSR Input Data")
    Data2.RecordSource = "SELECT * FROM MASTER WHERE CASE_NO LIKE '" & GetAuto$ & "" ' ""
    End Sub

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Is case_no text or numeric?

    Do you want to get an exact match or can the user enter a partial case_no?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    well it would be an exact match

    thanks

  4. #4
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    An exact match for Char text would be

    Data2.RecordSource = "SELECT * FROM MASTER WHERE CASE_NO = '" & GetAuto$ & "'"

    An exact match for a numeric field would be

    Data2.RecordSource = "SELECT * FROM MASTER WHERE CASE_NO =" & clng(GetAuto$)


    The database field CASE_NO will drive which format you use.

    [Edited by JHausmann on 03-28-2000 at 07:17 PM]

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    The numeric field would have to be defined in the access database as such

    because I gave it a text property in the database even though it is always numbers; what would be the benefit of changing it to numeric? How does it help -- with the integrity or are there other good reasons

    Help a lamer is in the house!!!

  6. #6
    Lively Member
    Join Date
    Jan 2000
    Location
    Omaha, Ne
    Posts
    65

    Numerics

    Bebe,
    How are you using the data in the numeric field. If you are doing any math against the field then you would probably want it numeric. If it is a display type only field then it isn't as important (although if it is always going to be numeric I would make it numeric because it makes it easier to query against it). :P


    If it was text then "0003", "003" and "3" would be different where a numeric value would be identical (3).

Posting Permissions

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



Click Here to Expand Forum to Full Width