No record found on new table

  • Thread starter Jânio via AccessMonster.com
  • Start date
J

Jânio via AccessMonster.com

Hi,

I create a table in VBA. I can see this table after pressing F5 table screen
of Access.
What I actualy try to do is create a table in VBA then setting a record set
to this newly created table and to write to the table.
After the:
tb.edit
I get the error message no current record set.
Is there maybay a way of refreshing the database first?

Regards,

Jânio
 
C

chris.nebinger

You'll have to include the code you are using to create the table and
write to it.

Creating a table uses either an Make Table SQL statement, or
DAO.TableDef object, or some similar manner. Writing data uses a DAO
or ADO recordset, or an Insert SQL statement.



Chris
 
M

Marshall Barton

Jânio via AccessMonster.com said:
I create a table in VBA. I can see this table after pressing F5 table screen
of Access.
What I actualy try to do is create a table in VBA then setting a record set
to this newly created table and to write to the table.
After the:
tb.edit
I get the error message no current record set.
Is there maybay a way of refreshing the database first?


You need to use tb.AddNew instead of tb.Edit. AddNew is
used to create new records and Edit is used to modify
existing records.
 
D

David C. Holley

Please post the full code that you're using. Before you can actually
write to the table, you have to set a recordSet object pointing to the
table.
 
D

David C. Holley

And for convinence here's some sample code

Dim rs as DAO.RecordSet

Set rs = CurrentDB.OpenRecordset([tableName])

rs.AddNew
rs.Fields([fieldName]) = "Hello"
rs.Update
rs.Close

Set rs = nothing
 
J

janiotjoeawie via AccessMonster.com

David said:
And for convinence here's some sample code

Dim rs as DAO.RecordSet

Set rs = CurrentDB.OpenRecordset([tableName])

rs.AddNew
rs.Fields([fieldName]) = "Hello"
rs.Update
rs.Close

Set rs = nothing
[quoted text clipped - 10 lines]

Thankx,

The rs.addnew did it.
After a long day of working I sometimes do not see this errors anymore.

Jânio
 
Top