Accessing Table with VBA Code

C

Chin Bhat

Hi,

I am currently using the following code in my form:

Private Sub Form_Load()
Set dbs = CurrentDb
Set doc = dbs.Containers("Databases")!UserDefined


Me.PreSearchStores = doc.Properties!PRS
Me.PostSearchStores = doc.Properties!POS
..
..
..


I am trying to write to a table. Some values are entered
by the user and others are internal and are being written
using the code above. The problem is, the code above
always writes one record down from the rest of the data.
The CurrentRecord is 1 but it still writes on line down.
Can someone please help me fix this problem?

Thanks a lot.

Chin Bhat.
 
M

Mike Labosh

I am trying to write to a table. Some values are entered
by the user and others are internal and are being written
using the code above. The problem is, the code above
always writes one record down from the rest of the data.
The CurrentRecord is 1 but it still writes on line down.
Can someone please help me fix this problem?

Air code:

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDB
Set rs = db.OpenRecordset("SELECT * FROM TableName WHERE...")

rs.Edit
rs!ThisColumn = NewValue
rs.Update

rs.Close

Set rs = Nothing
Set db = Nothing

You could also do it with an update query, if that sounds more reasonable.

--
Peace & happy computing,

Mike Labosh, MCSD

Feed the children!
Save the whales!
Free the mallocs!
 
Top