私はこのコードVBAのアクセスがエラー91
Public Sub Production_UpdateStatus(ByVal lngProductionId As Long, _
ByVal NewProductionStatus As eProductionStatus)
Dim oDb As DAO.Database
Dim oRst As DAO.Recordset
Dim StrSql As String
Dim strProductionStatus As String
On Error GoTo Err_Infos
GetCurrentProductionStatusString NewProductionStatus, strProductionStatus
Set oDb = CurrentDb
'Mise a jour du staut de production
StrSql = "UPDATE tProduction SET tProduction.Statut= '" & strProductionStatus & "'" _
& " WHERE (tProduction.IdProduction=" & lngProductionId & ");"
oDb.Execute StrSql
'Fermeture des connexions
oRst.Close
oDb.Close
Set oDb = Nothing
Set oRst = Nothing
Exit_currentSub:
Exit Sub
Err_Infos:
MsgBox "Erreur #" & Err.Number & " : " & Err.Description
Resume Exit_currentSub
End Sub
にこのコードの作業を実行しますが、エラーに私に
それを設定していない91
オブジェクト変数またはWithブロック変数を与えることを試みます次のSQLクエリを生成します。
UPDATE tProduction SET tProduction.Statut= 'Nouvelle' WHERE (tProduction.IdProduction=2);
私は直接クエリをテストするとき、私はエラーがありません。このエラーを取り除く手助けをしてもらえますか?
ありがとうございました
エラーとは何ですか? –
oRst.Closeを削除し、oRst = Nothing行を設定します。 oRstは初期化されていないため、エラーが発生しますが、このコードではoRstは必要ありません。 – RADO
このエラーは 'oDb.Execute StrSql'で発生しますか? VBAではセミコロンは必要ありませんが、私はそれが原因だとは思いません。 –