Link to home
Start Free TrialLog in
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!
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

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
Avatar of galo_6
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
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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??
Avatar of 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 .