By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,890 Members | 1,236 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,890 IT Pros & Developers. It's quick & easy.

Adding data records

P: n/a
Hi, hope someone can help with the following, I'm a bit stuck!

I have a database table (Access) with an AutoNumber field. When I add data
to the table I want to use the AutoNumber field, format it and save the
result in another field within the same record.

Using SQL I can "Insert Into..." without a problem but Access doesn't have
any call back features so I don't know what the AutoNumber field contains.

In old ADO I used to open an empty recordset-
Rst.Open"Select * from myTable where 0=1;", DBConnection) and then manually
add the record-
Rst!FormatField=format(Rst!ID,"00000000")
Rst!Update

I assume I'll have to use a DataTable to achieve this, I've played about a
bit, I can 'seemingly' add a record to a table I've loaded, but can't save
the changes back to the database.

Any ideas?

Cheers,
Tull.
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Wed, 15 Jun 2005 12:16:04 +0000 (UTC), "Tull Clancey" <tu**********@btopenworld.com> wrote:

Hi, hope someone can help with the following, I'm a bit stuck!

I have a database table (Access) with an AutoNumber field. When I add data
to the table I want to use the AutoNumber field, format it and save the
result in another field within the same record.

Using SQL I can "Insert Into..." without a problem but Access doesn't have
any call back features so I don't know what the AutoNumber field contains.

In old ADO I used to open an empty recordset-
Rst.Open"Select * from myTable where 0=1;", DBConnection) and then manually
add the record-
Rst!FormatField=format(Rst!ID,"00000000")
Rst!Update

I assume I'll have to use a DataTable to achieve this, I've played about a
bit, I can 'seemingly' add a record to a table I've loaded, but can't save
the changes back to the database.


See if the following helps:

HOW TO: Retrieve the Identity Value While Inserting Records into Access Database By Using Visual
Basic .NET
http://support.microsoft.com/kb/815629/EN-US/
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 21 '05 #2

P: n/a
Yes I found this, but it's incredibly long winded. Is there no way anymore
to simply access a data record?
"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:h8********************************@4ax.com...
On Wed, 15 Jun 2005 12:16:04 +0000 (UTC), "Tull Clancey"
<tu**********@btopenworld.com> wrote:

Hi, hope someone can help with the following, I'm a bit stuck!

I have a database table (Access) with an AutoNumber field. When I add
data
to the table I want to use the AutoNumber field, format it and save the
result in another field within the same record.

Using SQL I can "Insert Into..." without a problem but Access doesn't
have
any call back features so I don't know what the AutoNumber field
contains.

In old ADO I used to open an empty recordset-
Rst.Open"Select * from myTable where 0=1;", DBConnection) and then
manually
add the record-
Rst!FormatField=format(Rst!ID,"00000000")
Rst!Update

I assume I'll have to use a DataTable to achieve this, I've played about
a
bit, I can 'seemingly' add a record to a table I've loaded, but can't
save
the changes back to the database.


See if the following helps:

HOW TO: Retrieve the Identity Value While Inserting Records into Access
Database By Using Visual
Basic .NET
http://support.microsoft.com/kb/815629/EN-US/
Paul
~~~~
Microsoft MVP (Visual Basic)

Nov 21 '05 #3

P: n/a
On Wed, 15 Jun 2005 14:43:08 +0000 (UTC), "Tull Clancey" <tu**********@btopenworld.com> wrote:

Yes I found this, but it's incredibly long winded. Is there no way anymore
to simply access a data record?


Not if you're using auto increment data types.
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.