Avatar of galo_6
galo_6
 asked on

How to know autonumber field from a table in Visual Basic


 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.

 Thanks!
Visual Basic Classic

Avatar of undefined
Last Comment
galo_6

8/22/2022 - Mon
Éric Moreau

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
galo_6

ASKER
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
adodc1.Recordset.MovePrevious

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

 adodc1.Recordset.MoveNext  
 
  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.
ASKER CERTIFIED SOLUTION
Éric Moreau

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
galo_6

ASKER
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??
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
galo_6

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