|
-
May 28th, 2007, 03:54 AM
#1
Thread Starter
Fanatic Member
[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
-
May 28th, 2007, 07:11 AM
#2
Thread Starter
Fanatic Member
Re: Beacon's Tutorial - Part 5 ????
Now it’s getting scary, I fixed this myself
Code:
RS11.Find "[NeedleName] = '" & Combo8.Text & "'"
-
May 28th, 2007, 08:44 AM
#3
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)
-
May 28th, 2007, 01:31 PM
#4
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|