私はAccess 2007を使用しており、いくつかのリンクテーブルをmySQLデータベースに持っています。私は、MySQLがテーブルをリンクにレコードを挿入するためにDAOを使用し、Select @@アイデンティティを使用して挿入PKを取得しようとしているが、その選択は、私は満足していないanother question like this,を見てきました0@@ Identityを選択して、アクセス先のリンクテーブルを0に戻します。
Dim sql As String
Dim oDB As Database
Set oDB = CurrentDb
sql = "INSERT INTO Quotes (CustomerID) SELECT 1 AS Expr1;"
oDB.Execute sql
If oDB.RecordsAffected <> 1 Then
MsgBox "cannot create new quote"
Exit Function
End If
Dim rsNewID As DAO.Recordset
Set rsNewID = oDB.OpenRecordset("SELECT @@IDENTITY") ' Create a recordset and SELECT the new Identity
Dim intNewID As Long
intNewID = rsNewID(0).Value ' Store the value of the new identity in variable intNewID
'This value is 0, why?
戻っているのです私のために答えた
うれしいです! :) – fredrik