Add new record with coding. 
Author Message
 Add new record with coding.

Hi

When I run this code I got the following message:

Run-Time error '438'
Object doesn't support this property or method

Can someone tell me what's wrong with it? Thanks!

Chris

=================

    Dim con As Object
    Dim rs As Object
    Dim stSql As String

    ' Open the table of Switchboard Items, and find
    ' the first item for this Switchboard Page.
    Set con = Application.CurrentProject.Connection
    stSql = "SELECT * FROM [tbR01]"
    Set rs = CreateObject("ADODB.Recordset")
    rs.Open stSql, con, 1, 3 ' 1 = adOpenKeyset

    rs.Add                *** Code stop here ****
    rs("R01") = "test"
    rs.Update

    rs.Close
    Set rs = Nothing
    Set con = Nothing



Sat, 08 Jan 2005 01:28:44 GMT  
 Add new record with coding.
Recordsets don't have an Add method, they have an AddNew method.

--
Brendan Reynolds (MVP)

Access 2000/2002 sample app at
http://brenreyn.brinkster.net
----------------------------

Quote:
> Hi

> When I run this code I got the following message:

> Run-Time error '438'
> Object doesn't support this property or method

> Can someone tell me what's wrong with it? Thanks!

> Chris

> =================

>     Dim con As Object
>     Dim rs As Object
>     Dim stSql As String

>     ' Open the table of Switchboard Items, and find
>     ' the first item for this Switchboard Page.
>     Set con = Application.CurrentProject.Connection
>     stSql = "SELECT * FROM [tbR01]"
>     Set rs = CreateObject("ADODB.Recordset")
>     rs.Open stSql, con, 1, 3 ' 1 = adOpenKeyset

>     rs.Add                *** Code stop here ****
>     rs("R01") = "test"
>     rs.Update

>     rs.Close
>     Set rs = Nothing
>     Set con = Nothing



Sat, 08 Jan 2005 01:58:25 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. adding new records & new record

2. How to add new records in a new database

3. deleting records in a table and then adding new records

4. ADO2.5, can't add new record to an empty table using record binding

5. Moving from New Record to Existing Record in Code

6. How to add new record to table in external location

7. How to launch a Macro/Module when new record is added to table

8. Adding new record with autonumbered PK

9. Letting Access Form Add New Record

10. Help with adding new record to a table.

11. Adding new record

12. Can't add new records when using Linked forms

 

 
Powered by phpBB® Forum Software