Results 1 to 7 of 7

Thread: URGENT: Searching with ADO for matches

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    29
    Hoping for some advice here:

    I am currently using Visual Basic 6 with Microsoft Access to enter tool information into a tooling database.

    In this front-end application I have a form for ordering new tools with a couple of text boxes and a drop down combo.

    What I need to be able to do is search the existing records in a table called Tool_Order for an exact match to the data entered in to the form so that I can warn the user if they attempt to order the same tool again.

    The Tool_Order table from access is in a datagrid filled from an adodc connection and in the code I have used ADO to update the information stored in the Access tables.

    How can I search the datagrid fields for matches to the text box inputs? Is there another way with the method I am using (ADO)?

    Any help greatly appreciated..

  2. #2

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    29
    The only method I can think of is to create a new recordset and check to see if it is empty or not. Here's my code:

    strQuery = "SELECT DISTINCTROW Tips.Tip_Size_ID, Tips.Tip_Size_OD, Tip_Types.Tip_Description FROM Tip_Types INNER JOIN Tips ON Tip_Types.Tip_Type_ID = Tips.Tip_Type_ID WHERE (((Tips.Tip_Size_ID)=txtTipsize.Text) AND ((Tips.Tip_Size_OD)=txtTipsize2.Text) AND ((Tip_Types.Tip_Description)=cboTipTypes.Text))"
    rsQuery.Open strQuery, myConnection, adOpenDynamic, adLockOptimistic

    If rsQuery.RecordCount > 0 Then

    If (MsgBox("An exact match of the tool you are ordering is already selected for ordering. Do you wish to order another?", vbQuestion) = vbYes) Then

    I get an object variable or with block not set error with this code so I'm guessing I haven't used the correct format for my SQL statement. Can I use txtTipsize.text in the statement in that format? Can anyone see what the problem is?

  3. #3
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    ???

    Did you declare the recordset in this function???

    Code:
    dim rsQuery as New Recordset
    Hope this helps

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    29
    sure did

  5. #5
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Talking

    Hi spooked

    Your 99% There just change it to this

    strQuery = "SELECT DISTINCTROW Tips.Tip_Size_ID, Tips.Tip_Size_OD, Tip_Types.Tip_Description FROM Tip_Types INNER JOIN Tips ON Tip_Types.Tip_Type_ID = Tips.Tip_Type_ID WHERE (((Tips.Tip_Size_ID)='" & txtTipsize.Text & "'") AND ((Tips.Tip_Size_OD)='" & txtTipsize2.Text & "') AND ((Tip_Types.Tip_Description)='" & cboTipTypes.Text & "'"))"

    The single pips I put in are providing all the fields are strings.

    Hope this helps

    Ian


    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  6. #6

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    29
    Seem to be getting error after txtTipsize.Text & "'")

    Error

    Expected: End of statement


  7. #7
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Smile

    Sorry Spooked

    change the "'"))" ath the end to "'))"


    Ian

    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

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