How to know autonumber field from a table in Visual Basic

Posted on 2003-02-21
Medium Priority
Last Modified: 2013-12-25

 Hi... I'm a newbie at Visual Basic. I'm building a database application using Access.  The main problem I'm having now is that I save an image with certain name, according with the id of the product.  E.g.:
 Product ID:  177
 company ID:  2

 The image should be saved as 2-177.bmp

 I'm using adodc1.recordset.Addnew to add the new register in the database, but I can't find an easy way to get the productid number (autonumber field). I would appreciate if someone can help me.

Question by:galo_6
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 70

Expert Comment

by:Éric Moreau
ID: 7999344
You will need to add a new entry to your table, retrieve the ID number and then save your picture.

see http://support.microsoft.com/default.aspx?scid=kb;en-us;244779

Author Comment

ID: 8001728
Emoreau: I've just read the URL you mentioned and I don't see a clear answer to my problem.  

 I'm using adodc to retrieve the records from the database.  I have a textbox (lets say Text1) connected to the field productid  Text1.Datafield = productid . I'm using

 to save the changes to the database and then I go back to grab the productid ....

  My problem is that the productid isn't available.  All the other text boxes are populated with the info from the database except the one with the productid info.
LVL 70

Accepted Solution

Éric Moreau earned 150 total points
ID: 8002957
I have pasted the wrong link. Sorry. Here is a better one: http://support.microsoft.com/default.aspx?scid=kb;en-us;244136

Author Comment

ID: 8017281
In your link I understood, that the only way I can get the autonumber is using Access 2000 and Jet 4.0.

 I migrated to Access 2000 (i was using 97), but still I can't use Jet 4.0. I created a new database in access 2000 just for testing, but when I build the connection for the ADODC, there is an error: Error in the connection test when initializing provider.   (this is just a translation because my system is Spanish).

 Why I can't use this database??

Author Comment

ID: 8017565
The error was that I had the database open.  I closed it and now I can use Access 2000 and Jet 4.0 .

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question