Hello,
I am trying to modify (in a continous form) two differents records when you modify one..
I can see only one in the form.
The records are coming from the same table.
Error comes from qdf.parameters( quote number)
Thank you for your help
Someone tell me maybe to do something like that but i don't know if it s correct.
I am trying to modify (in a continous form) two differents records when you modify one..
I can see only one in the form.
The records are coming from the same table.
Error comes from qdf.parameters( quote number)
Code:
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("QrytblRoutingMain Routing2")
qdf.Parameters("QUOTE NUMBER") = [Forms]![frmAssemblyGeneralInfo]![QUOTE NUMBER]
qdf.Parameters("COMPPN") = [Forms]![frmAssemblyGeneralInfo]![frmSubAssemblyEnterPriceNew].[Form]![COMPPN]Set rst = qdf.OpenRecordset()
If rst.RecordCount <> 0 Then
seqNo = rst.Fields("Seq")
quoteNo = rst.Fields("[QUOTE NUMBER]") & "CONT1"
cPN = rst.Fields("COMPPN")
routingStr = rst.Fields("ROUTING")
strUpdateQuery = "UPDATE tblRoutingMain SET tblRoutingMain.[SEQ] = '" & seqNo & "'" & _
"WHERE [tblRoutingMain].[QUOTE NUMBER] = '" & quoteNo & "' AND [tblRoutingMain].COMPPN = '" & cPN & "'" & "' AND [tblRoutingMain].[ROUTING] = " & routingStr
CurrentDb.Execute strUpdateQuery, dbFailOnError
End If
Exit_SEQ_AfterUpdate:
Exit Sub
Err_SEQ_AfterUpdate:
Call errorhandler1_MsgBox("Form: " & TypeName(Me) & ", Subroutine: SEQ_AfterUpdate()")
Resume Exit_SEQ_AfterUpdate
End If
Someone tell me maybe to do something like that but i don't know if it s correct.
Code:
Private Sub SEQ_AfterUpdate()
On Error GoTo Err_SEQ_AfterUpdate
Dim quoteNo As String, seqNo As String
Dim cPN As String
Dim routingStr As String
Dim daoDB As DAO.Database
Dim daoQDF As DAO.QueryDef
Dim daoPRM As DAO.Parameter
Dim daoRS As DAO.Recordset
Dim strQryName As String
strQryName = "QrytblRoutingMain Routing2"
PARAMETERS projectid integer;
SELECT [p].[QUOTE NUMBER],
[p].[COMPPN],
[p].[SEQ],
[p].[ROUTING],
FROM [tblRoutingMain] AS [p]
WHERE [p].[QUOTE NUMBER] = uiutils_ReadFormTextBox(Me.[QUOTE NUMBER],vbNullString) AND [p].[COMPPN=uiutils_ReadFormTextBox([Forms]![frmAssemblyGeneralInfo]![frmSubAssemblyEnterPriceNew].[Form]![COMPPN],vbNullString)
ORDER BY [p].[ROUTING];
Set daoDB = CurrentDb()
Set daoQDF = daoDB.QueryDefs(strQryName)
Set daoPRM = daoQDF.Parameters!projectid
daoPRM = 1
Set daoRS = daoQDF.OpenRecordset()
If daoRS.RecordCount <> 0 Then
seqNo = daoRS.Fields("Seq")
quoteNo = daoRS.Fields("[QUOTE NUMBER]") & "CONT1"
cPN = daoRS.Fields("COMPPN")
routingStr = daoRS.Fields("ROUTING")
strUpdateQuery = "UPDATE tblRoutingMain SET tblRoutingMain.[SEQ] = '" & seqNo & "'" & _
"WHERE [tblRoutingMain].[QUOTE NUMBER] = '" & quoteNo & "' AND [tblRoutingMain].COMPPN = '" & cPN & "'" & "' AND [tblRoutingMain].[ROUTING] = " & routingStr
CurrentDb.Execute strUpdateQuery, dbFailOnError
End If
daoQDF.Close
'Clean up the connection to the database
Set daoRS = Nothing
Set daoPRM = Nothing
Set daoQDF = Nothing
Set daoDB = Nothing
Exit_btnEdit_Click:
Exit Sub
Err_SEQ_AfterUpdate:
Call errorhandler_MsgBox("Form: " & TypeName(Me) & ", Subroutine: SEQ_AfterUpdate ()")
Resume Exit_SEQ_AfterUpdate
Comment