|
-
September 14th, 2003, 07:04 PM
#1
Run-time error 3800. Problem with table index.
Hello.
My program reads records from an mdb database and populates a listview. I want to be able to delete a record from the database, the one which is selected in the listview.
The database has a table "Main" which has "ID" as the primary key (I keep these values in the Listview.ListItems.Item(ItemIndex).Tag.
Now I have the following:
Dim DB As Database
Dim RS As Recordset
Set DB = OpenDatabase(App.Path & "\Database\Database.mdb")
Set RS = DB.OpenRecordset("Main")
RS.MoveFirst
RS.Index = ("ID")
At the above command, I have a run-time error '3800':
'ID' is not an index in this table.
Can you tell me what's wrong? From what I understand, it means that "ID" is a wrong name (but it isn't really).
Visit www.greekroms.net
Greek translations of roms
-
September 15th, 2003, 07:21 AM
#2
May i comment
May be this helps...
Code:
Dim DB As Database
Dim RS As Recordset
Dim Items as ListItem
Set DB = OpenDatabase(App.Path & "\Database\Database.mdb")
'Fields Must Be Selected To Index or Fetch Fields Value
Set RS = DB.OpenRecordset("SELECT * FROM Main")
RS.MoveFirst
Do While Not .EOF
'RS.Index = ("ID") 'What is the purposed?
Set Items = ListView1.ListItems.Add( , CSTR(RS!ID), RS!FieldName)
Items.SubItems(1) = RS!FieldName
'....................
RS.MoveNext
Loop
I May Have Misinterpret U'r Post
Correct Me If I Am Wrong.........//
Enjoy Coding............................//
zak2zak
-
September 15th, 2003, 12:35 PM
#3
Thanks for answering zak2zak :-)
I wasn't clear though...
I don't want to populate my listview, I have already done this.
I want to delete a record from an access database.
The name of the table is "Main", the primary key is "ID" and I have it (for example "30").
My code has the following:
Dim DB As Database
Dim RS As Recordset
Set DB = OpenDatabase(App.Path & "\Database\Database.mdb")
Set RS = DB.OpenRecordset("Main")
RS.MoveFirst
RS.Index = ("ID") 'Here is the error!
RS.Seek "=", Gamelist.ListItems.Item(ItemIndex).Tag
RS.Delete
Visit www.greekroms.net
Greek translations of roms
-
September 15th, 2003, 01:36 PM
#4
try
RS.Index = "ID" 'Here is the error!
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
|