Salsaboy60
Technical User
Hello,
I have a form Orders (with sub-form) and in case of a delivery less then qte ordere (back-order) I like to duplicate the order line and create a backorder.
I try to do so with a duplicate recordset and i tryed with an query Insert Into, but in both cases I get errors.
I am not very at ease with this kind of work and it would be nice if someone could help me, or indicate me where i am mistaken.
The code for the recordset is :
I get a error on : Set rstAdd = qd.OpenRecordset
And the case with sql is like this :
The error is on the line DoCmd.RunSql strSql.
I would appreciate if someone can help me, because i am stuck for several days now. I lake of knowledge on this matter, and i did not find any real help on the internet.
Thanks in advance.
Hans
I have a form Orders (with sub-form) and in case of a delivery less then qte ordere (back-order) I like to duplicate the order line and create a backorder.
I try to do so with a duplicate recordset and i tryed with an query Insert Into, but in both cases I get errors.
I am not very at ease with this kind of work and it would be nice if someone could help me, or indicate me where i am mistaken.
The code for the recordset is :
Code:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qd As DAO.QueryDef
Set dbs = CurrentDb
Set qd = dbs.QueryDefs!rqtDuplication 'Query where update is going to be
Set rstAdd = qd.OpenRecordset
Set rst = Me.RecordsetClone
rst.AddNew
rst!N°Document = Document
rst!N°IdProduit = Me.N°IdProduit
rst!Désignation = Nz(Me.Désignation)
rst![Qte Commandee] = Nz(Me.Qte_Commandee)
rst!Mouvements = Nz(Me.Mouvements)
rst!Emplaçement = Nz(Me.Emplaçement)
rst![Date modification] = Nz(Me.DateModification)
rst!IDMagasin = Me.N°IdMagasin
rst.Update
rst.Close
CurrentDb.Close
And the case with sql is like this :
Code:
Dim strSql As String
Dim strN°Document As String
Dim strN°IdProduit As String
Dim strDésignation As String
Dim strQteCmd As String
Dim strMouvements As String
Dim strEmplacement As String
Dim strDateModification As String
Dim strprixAchatUHT As String
Dim strIDMagasin As String
strN°Document = DMax("[BackOrderID]", "BackOrder")
strN°Document = strN°Document + 1
strN°IdProduit = Me.N°IdProduit
strDésignation = Nz(Me.Désignation)
strQteCmd = Nz(Me.Qte_Commandee)
strMouvements = Nz(Me.Mouvements)
strEmplaçement = Nz(Me.Emplaçement)
strDateModification = Nz(Me.DateModification)
strIDMagasin = Me.N°IdMagasin
strSql = "INSERT INTO Detailstock (" & strN°Document & "," & strN°IdProduit & "," & _
strDésignation & "," & strQteCmd & "," & strMouvements & "," & strEmplacement & "," & _
strDateModification & "," & strIDMagasin & ")"
strSql = strSql + " SELECT DetailStock.N°Document, DetailStock.N°IdProduit, DetailStock.Désignation, " & _
'"DetailStock.[Qte Commandee], DetailStock.Mouvements, DetailStock.Emplaçement, " & _
"DetailStock.[Date modification], DetailStock.N°IDMagasin FROM DetailStock;"
DoCmd.RunSQL strSql
The error is on the line DoCmd.RunSql strSql.
I would appreciate if someone can help me, because i am stuck for several days now. I lake of knowledge on this matter, and i did not find any real help on the internet.
Thanks in advance.
Hans