Hi
i have a form invoice that contains some fields about the client, date etc.. and have a subform that contains the details of the invoice. So what i want to do is when the user enter a code like pn for tire it adds automatically a line in the table for the tire tax.
I am able to add this line automatically but when i requery my tables it goes to the first record of this table and the client have to schroll down to return to the line he was working on.
is there a way to add a line in the table and return to the exact record he was working on? in this case i want to return to the line pn on the field description.
heres the code i use:
Dim Base As Database
Dim RstPiece, RstDetailFacture As Recordset
On Error Resume Next
Set Base = CurrentDb
If Me.IdPiece.Column(1) = "PN" Then
Set RstDetailFacture = Base.OpenRecordset("SELECT * from detailfacture")
With RstDetailFacture
.AddNew
!IDFacture = Forms!facturation!IDFacture
!DateFacture = Forms!facturation!DateFacture
!IdPiece = 11 ' tire tax code
.Update
End With
End If
Set RstPiece = Base.OpenRecordset("select * from piece where idpiece = " & Me.IdPiece)
If Not RstPiece.EOF Then
'Me.DescItem = RstServices!DescServiceVente
Me.DescItem = RstPiece!DescPiece
Me.Vendant = RstPiece!PrixVendant
End If
Me.Requery
RstPiece.Close
Set Base = Nothing
thanks a lot and have a nice day
i have a form invoice that contains some fields about the client, date etc.. and have a subform that contains the details of the invoice. So what i want to do is when the user enter a code like pn for tire it adds automatically a line in the table for the tire tax.
I am able to add this line automatically but when i requery my tables it goes to the first record of this table and the client have to schroll down to return to the line he was working on.
is there a way to add a line in the table and return to the exact record he was working on? in this case i want to return to the line pn on the field description.
heres the code i use:
Dim Base As Database
Dim RstPiece, RstDetailFacture As Recordset
On Error Resume Next
Set Base = CurrentDb
If Me.IdPiece.Column(1) = "PN" Then
Set RstDetailFacture = Base.OpenRecordset("SELECT * from detailfacture")
With RstDetailFacture
.AddNew
!IDFacture = Forms!facturation!IDFacture
!DateFacture = Forms!facturation!DateFacture
!IdPiece = 11 ' tire tax code
.Update
End With
End If
Set RstPiece = Base.OpenRecordset("select * from piece where idpiece = " & Me.IdPiece)
If Not RstPiece.EOF Then
'Me.DescItem = RstServices!DescServiceVente
Me.DescItem = RstPiece!DescPiece
Me.Vendant = RstPiece!PrixVendant
End If
Me.Requery
RstPiece.Close
Set Base = Nothing
thanks a lot and have a nice day