Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing to Access Using ADO

Status
Not open for further replies.

Kori

Programmer
Oct 17, 2000
35
US
Can anyone give me insight on how to write to a Access database using ADO. I know you use the

rst.addnew

'do the writing

rst.update

commands but it gives me errors. I think I need to make the database a read/write db but how??? and where????
 
yep, copy this and save it
--------------------------------------------
for Access 2000 databases
--------------------------------------------

Dim Conn2 As ADODB.Connection
Dim Rs1 As ADODB.Recordset

Dim SQLCode As String

Set Conn2 = CurrentProject.Connection ' <<<<Note same as CurrentDb

Set Rs1 = New ADODB.Recordset

SQLCode = &quot;SELECT * FROM [STOCK CODE LOOKUP] WHERE STOCK_CODE = '&quot; & Me![Part Number] & &quot;';&quot;
Rs1.Open SQLCode, Conn2, adOpenStatic, adLockOptimistic

Note: do normal rs1! or rs1. stuff from now on
like Rs1!fieldname
Rs1.addnew


' close it this way
Set rs1 = nothing
Set Conn2 = nothing

If you don't close it you will get an error when you try to reopen it.
Its not like DAO which closes things for you.

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top