Results 1 to 5 of 5

Thread: Many problems (Sql Statements)

  1. #1

    Thread Starter
    Lively Member chongo 2002's Avatar
    Join Date
    Apr 2000
    Posts
    106

    Unhappy

    How do I get the results of a query to show in text boxes? The query works and shows the results but it also adds all the other fields in the database after the matches. I only want matches to show.

    Code:
    'sql statement
    with db
    Set rs3 = db1.OpenRecordset("SELECT * " & "FROM [entered] WHERE [RiderNumber] = '" & listry.List(I) & "'", dbOpenDynaset)
    
    With rs3
    .edit
    txtname = ![RiderName]
    txtnumber = ![RiderNumber]
    txtother = ![other]
    end with
    end with
    Also How do you use the .findfirst method for numbers? If I use a number field it says data type conversion error.

    Hope someone can help.


    [Edited by chongo 2002 on 09-30-2000 at 08:35 PM]

  2. #2
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    Perhaps you can try this to show the fields in your Textboxes without adding anything to your database (Don¡¯t use .Edit or .AddNew or .Update or anything like those BEFORE you show the fields content.Use them ONLY when you want to add or modify something in the database.).

    Code:
    ____________________________________________________________
    With rs3
    txtname = !RiderName
    txtnumber = !RiderNumber
    txtother = !other
    End With
    ____________________________________________________________

    You could try using .FindFirst in this way to locate numbers:

    Code:
    ____________________________________________________________
    ¡®Suppose your RiderNumber field is a Byte field
    .FindFirst ¡°RiderNumber = ¡° & Cbyte(105)

    ¡®Suppose your RiderNumber field is an Integer field
    .FindFirst ¡°RiderNumber = ¡° & Cint(105)

    ¡®And so on
    ____________________________________________________________

    By the way, did you actually use those square brackets in your code? Try deleting them.

    ___________________________________________________________
    Visual Basic Professional 6.0


    [Edited by xmin on 09-30-2000 at 10:46 PM]

  3. #3

    Thread Starter
    Lively Member chongo 2002's Avatar
    Join Date
    Apr 2000
    Posts
    106

    Question

    The .findfirst method doesn't matter I want to use sql. But the numbers don't work in the sql query either. Data type conversion error.

    And no I didn't use the brackets in my code I forgot to remove them, but they don't hurt anything.

  4. #4
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    Ahhhh, I didn¡¯t seem to get your message. I see where you went now.
    If your "RiderNumer" field is a numeric (i.e., Byte, Integer, Long, etc.) one, try to use the SQL statement in this way:

    Code:
    ____________________________________________________________

    Set rs3 = db1.OpenRecordset("SELECT * " & "FROM [entered] WHERE [RiderNumber] = " & Val(listry.List(I)), dbOpenDynaset)

    ____________________________________________________________

    N.B.: Listed items are strings. So when you said your SQL statement worked that implies that your "RiderNumber" field is a Text field. That is perhaps the reason why you got the error message with numbers in the SQL.

    If you still have problems, tell me.

    Wish you every success.

    ____________________________________________________________
    Visual Basic Professional 6.0

  5. #5

    Thread Starter
    Lively Member chongo 2002's Avatar
    Join Date
    Apr 2000
    Posts
    106

    Talking

    Thanks got evrything workin Great!!!!

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