Click to See Complete Forum and Search --> : Simple Access Question II
Dragev
Oct 2nd, 2000, 06:42 AM
I have a table with 1024 records.
Register Value
----------------
1 13
2 1254
3 4543
4 135
etc.--> 1024
----------------
How the hell do I write a value to "Value" in a specific record when I know what record (e.g 1000) I want to write to?
The only thing I've come up with, is MoveNext until I reach the desired record, but that's so slow!
Please help me, gurus and semi-gurus!
D
Gary.Lowe
Oct 2nd, 2000, 07:00 AM
Use some SQL then create a recordset as follows
dim rs as New ADODB.Recordset
sSQL = "SELECT * FROM [Your Table] WHERE [Your Field]=100;"
rs.Open sSQL
Hope this is of use
Dragev
Oct 2nd, 2000, 07:13 AM
Hmmm...
VB says:
-----------------------------
User-defined type not defined
-----------------------------
Dunnowattado!
Thanks anyway, but could you explain it a little bit more in detail, please?
D
Gary.Lowe
Oct 2nd, 2000, 07:26 AM
Sorry Dragev
This should explain it better.
Make sure in your references you have the Microsoft AtiveX Data Objects Library 2.1 checked as well.
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sSQL As String
'Open the connection to your database
Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open "C:\MyDB.mdb"
End With
'Enter your table name and field name where appropriate, also remeber to enclose the
'value in "" if it is a string value
'i.e. sSQL = "SELECT * FROM tblMain WHERE ID =1000;"
sSQL = "SELECT * FROM [Your Table] WHERE [Your Field] =[Your value];"
'Open the recordset based on the SQL string
Set rs = New ADODB.Recordset
With rs
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open sSQL, cnn
End With
Dragev
Oct 2nd, 2000, 07:46 AM
Thanks, man!
Great!
D
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.