Jul 18, 2001 #1 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????
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????
Jul 18, 2001 #2 DougP MIS Dec 13, 1999 5,985 US 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 = "SELECT * FROM [STOCK CODE LOOKUP] WHERE STOCK_CODE = '" & Me![Part Number] & "';" 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 http://www.barcodeone.com to see how Bar-codes can help you be more productive Upvote 0 Downvote
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 = "SELECT * FROM [STOCK CODE LOOKUP] WHERE STOCK_CODE = '" & Me![Part Number] & "';" 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 http://www.barcodeone.com to see how Bar-codes can help you be more productive