I am using vb6 to control a sqlServer database and need a little help.
I use a form to gather information about part inspections. The form has general information about the inspection (date/time, inspector, location, etc...) and the more specific information about the individual line items (part number, pass/fail, failure mode, etc...).
The general inspection info is in tblInspection.
The more specific info is in tblInspection_Detail.
When I enter a new record into tblInspection - How do I know the Record_ID (the indexing primary key) for the record I just added?
I need to retain the new Record_ID value so that I can use it to identify what inspection each line item is associated with.
I'm sure this is a pretty easy one, but I am at a loss right now.
If you table has an identity field then the field gets populated when you add a new record. Once you add the new record just check the field value as the pointer moves to that new record. Here is an example:
Dim cn as ADODB.Connection
Dim rs as ADODB.Recordset
Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!
Or try our Ask An Expert service to answer any of your questions!