I'm trying to set a default value to a field on each record in a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hannoudw
    New Member
    • Aug 2010
    • 115

    I'm trying to set a default value to a field on each record in a form

    @Jim
    you told me before that if i put code in the OnCurrent event of the form; then it would get executed for the current detail line whenever i change from one row to another.
    I have a Continuous Forms that contain these text box:
    txtArticle bound to 'Article' in table item
    txtPrice bound to 'Real_Price' in table item
    txtDiscountedPr ice bound to 'Price_After_Di scount' in table item
    txtCashMoney bound to 'Cash' in Invoice table

    and i want to every time that i insert an new article in the invoice to check weather the that article had a discount price or not , if yes i want to set the txtCashMoney to the 'Price_After_Di scount' , if not i want to set the value of the txtCashMoney to the 'Real_Price' .
    so i tried this code :
    Code:
    Private Sub Form_Current()
    If (IsNull(Forms![item1]![Price_after_discount])) Then
    Forms![item1]![prix_vente_unitaire] = Forms![item1]![Price]
    Else
    Forms![item1]!prix_vente_unitaire = Forms![item1]![Price_after_discount]
    End If
    End Sub
    but it's not working
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32662

    #2
    No. It wouldn't.

    What Jim told you was correct. How you're trying to use it is not.

    If you want code to run when you add a new record you need Form_BeforeInse rt() or Form_AfterInser t().

    Comment

    Working...