Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Access
Message
From
13/11/2001 23:01:14
Gavin Reid
L & M Marketing Pty Ltd
Frenchs Forest, Australia
 
 
To
13/11/2001 21:38:11
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Re: Access
Miscellaneous
Thread ID:
00581281
Message ID:
00581300
Views:
17
Hi E C,

I had a similar problem trying to find the value of an access autonumber field, I ended up using ADO instead of RV's. The following should give you something to go on. After you add the stores record in ADO the autonumber field ( stk_id ) will be available for you to use.
oDatabaseConnection = CreateObject("ADODB.Connection")

oDatabaseConnection.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mypath\mymdb.mdb")

oRstStores = CreateObject("ADODB.Recordset")
oRstStores.ActiveConnection = oDatabaseConnection
oRstStores.LockType = 3 && LockOptimistic
oRstStores.Source = "stores"
oRstStores.Open
oRstStores.AddNew

* ----- Add code to update the various fields in the stores table
oRstTransactions.Fields("storename") = "mystore"

oRstStores.Update

oRstTransactions = CreateObject("ADODB.Recordset")
oRstTransactions.ActiveConnection = oDatabaseConnection
oRstTransactions.LockType = 3 && LockOptimistic
oRstTransactions.Source = "transactions"
oRstTransactions.Open
oRstTransactions.AddNew

* ---- The following line sets stk_id to be the same as stk_id from the stores record
oRstTransactions.Fields("stk_id") = oRstStores.Fields("stk_id")
oRstTransactions.Fields("transactiondescription") = "mytransaction"
oRstTransactions.Update

oRstTransactions.Close
oRstStores.Close

oDatabaseConnection.Close

RELEASE oDatabaseConnection
RELEASE oRstStores
RELEASE oRstTransactions
Hope this helps,
Gavin...

>I use following 2 remote view to pool Ms Access table data.
>
>1. stores - store item detail, primary is is stk_id
>2. transaction - in and out transaction for store item.
>
>
>When I insert a record to stores table, I also need to update the transaction table. The stores table have the primary key stk_id, that is handle by Ms Access itself and that key is used to link with transaction table.
>
>My problem is once I insert a record to stores table, I need the primary key for stores table to update the transaction table, but don't know the key value that assign by Ms Access.
>
>Any way to know the stk_id when I insert a record to stores table?
>
>TIA.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform