Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to know autonumber field from a table in Visual Basic

Posted on 2003-02-21
5
Medium Priority
?
292 Views
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.

 Thanks!
0
Comment
Question by:galo_6
  • 3
  • 2
5 Comments
 
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
0
 

Author Comment

by:galo_6
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
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.
0
 
LVL 70

Accepted Solution

by:
É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
0
 

Author Comment

by:galo_6
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??
0
 

Author Comment

by:galo_6
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 .
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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

569 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