Results 1 to 4 of 4

Thread: [RESOLVED] Beacon's Tutorial - Part 5 ????

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Resolved [RESOLVED] Beacon's Tutorial - Part 5 ????

    Continuing my quest to move away from the evil of bound controls I have hit another brick wall



    Using bound controls have some code

    Code:
    AdodcNeedles.RecordSource = "SELECT * FROM Needles WHERE NeedleName = '" & Combo8.Text & "'"
    AdodcNeedles.Refresh
    RefA = AdodcNeedles.Recordset.Fields(2).Value
    RefB = AdodcNeedles.Recordset.Fields(3).Value
    RefC = AdodcNeedles.Recordset.Fields(4).Value
    RefD = AdodcNeedles.Recordset.Fields(5).Value
    RefE = AdodcNeedles.Recordset.Fields(6).Value
    RefF = AdodcNeedles.Recordset.Fields(7).Value
    RefG = AdodcNeedles.Recordset.Fields(8).Value
    This code currently goes to a line in a database table and then gets the values of the other fields in that line.
    Now I need to change this code to something like this

    Code:
    Set RS11 = New ADODB.Recordset
     RS11.Open "Needles", ConnectNeedles, adOpenKeyset, adLockPessimistic, adCmdTable
    
    RS11.???? = "SELECT * FROM Needles WHERE NeedleName = '" & Combo8.Text & "'"
    RS11.Update
    
    RefA = RS11.Fields(2).Value
    RefB = RS11.Fields(3).Value
    RefC = RS11.Fields(4).Value
    RefD = RS11.Fields(5).Value
    RefE = RS11.Fields(6).Value
    RefF = RS11.Fields(7).Value
    RefG = RS11.Fields(8).Value
    Its just that I cannot find an equivalent action for the select statement, any ideas

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: Beacon's Tutorial - Part 5 ????

    Now it’s getting scary, I fixed this myself


    Code:
    RS11.Find "[NeedleName] = '" & Combo8.Text & "'"

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: [RESOLVED] Beacon's Tutorial - Part 5 ????

    I'd recommend still using the Select statement, as it will be quicker and take less memory.

    Instead of opening a full table like this:
    Code:
     RS11.Open "Needles", ConnectNeedles, adOpenKeyset, adLockPessimistic, adCmdTable
    ..put your SQL statement into a variable, and change the open line, like this:
    Code:
    dim strSQL as String
     strSQL = "SELECT * FROM Needles WHERE NeedleName = '" & Combo8.Text & "'" 
     RS11.Open strSQL, ConnectNeedles, adOpenKeyset, adLockPessimistic, adCmdText
    (note that the .Update line is for writing and Edits you have made to the fields, so is not relevant where you have it)

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    May 2006
    Posts
    612

    Re: [RESOLVED] Beacon's Tutorial - Part 5 ????

    Many Thanks

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