I've two queries I'm trying to create with QueryDef.
This insert query works perfectly and I can assign the parameters:
Dim qryAddPackage As String: qryAddPackage = "" & _
"INSERT INTO `RMF_tblPackages` " & _
"(`SystemID`, `DoD`, `DateCreated`, `LastModified`, `LastUpdatedBy`) " & _
"VALUES ([SystemID], [DoD], NOW(), NOW(), [UID])"
With CurrentDb.CreateQueryDef(vbNullString, qryAddPackage)
.Parameters!SystemID.Value = cbbSystems.Value
.Parameters!DoD.Value = Me.txtDoD.Value
.Parameters!UID.Value = strGetUserID()
.Execute
End With
However, in this update query, I am only able to access the Parameter UID in the WHERE statement:
Dim qryUpdatePkg As String: qryUpdatePkg = "" & _
"UPDATE `RMF_tblPackages` " & _
"SET " & _
"`SystemID` = [SystemID], `DoD` = [DoD], `LastModified` = NOW(), `LastUpdatedBy` = [UID] " & _
" WHERE `PackageID` = [PackageID]"
With CurrentDb.CreateQueryDef(vbNullString, qryUpdatePkg)
.Parameters("SystemID").Value = cbbSystems.Value
.Parameters!DoD.Value = Me.txtDoD.Value
.Parameters!UID.Value = strGetUserID()
.Parameters!PackageID.Value = Me.lbxPackages.Value
.Execute dbSeeChanges
End With
In every other line trying to assign a parameter, it just says that the parameter's name is not in the collection.
I've tried assigning them like this:
.Parameters("PackageID").Value = Me.lbxPackages.Value
As well, but that doesn't work either.
I tried just running the update query with some data and it worked fine so the query works.
.Params.count returns 1 as you would expect given it's only recognizing one param.
Any other ideas as to why the parameters aren't being recognized by that update query?