Hi, this is my first post. Very happy to visit this web for getting help.
I use office2000
I create a database called db1.mdb
and have table named : customersAge
and have fields: ID, Name, Age
1 A 1
2 B 2
3 C 3
4 D 4
I would ask a quesiton about Changing a value in Age field
by VBA.
Dim MyDb As Database
Dim MyTable As Recordset
Set MyDb = DBEngine.Workspaces(0).Databases(0)
Set MyTable = MyDb.OpenRecordset("CustomersAge", DB_OPEN_TABLE)
MyTable.Index = "Age"
MyTable.MoveFirst
Do Until MyTable.EOF
If MyTable!Age = "2" Then
MyTable.EditMode
MyTable!Age = "14"
MyTable.Update
End If
Loop
The problem here is "Dim MyDb As Database"
Error message : Type undefined.
I chance Database to DAO.Database, but still not success.
Hope anyone can help me!!! Thanks a lot.
I use office2000
I create a database called db1.mdb
and have table named : customersAge
and have fields: ID, Name, Age
1 A 1
2 B 2
3 C 3
4 D 4
I would ask a quesiton about Changing a value in Age field
by VBA.
Dim MyDb As Database
Dim MyTable As Recordset
Set MyDb = DBEngine.Workspaces(0).Databases(0)
Set MyTable = MyDb.OpenRecordset("CustomersAge", DB_OPEN_TABLE)
MyTable.Index = "Age"
MyTable.MoveFirst
Do Until MyTable.EOF
If MyTable!Age = "2" Then
MyTable.EditMode
MyTable!Age = "14"
MyTable.Update
End If
Loop
The problem here is "Dim MyDb As Database"
Error message : Type undefined.
I chance Database to DAO.Database, but still not success.
Hope anyone can help me!!! Thanks a lot.