Field not updating...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hrprabhu
    New Member
    • May 2010
    • 83

    Field not updating...

    I have attached a small database. In the "sFrmIncrements " there is a field named "newIncreme nt" I am trying to update the field but is not working. I don't know why.

    Code:
    IIf(LookUp("incrementOf","tblPFST","tblPFST.serviceOf='" & [serviceType] & "' And tblPFST.rankOf='" & [rank] & "'")>[increment],[increment]+1,"N/A")
    is the data source for the field.

    If I try it in the intermediate window it is working.

    ? IIf(LookUp("inc rementOf","tblP FST","tblPFST.s erviceOf='1' And tblPFST.rankOf= 'CAPT'")>2,3+1, "N/A") is giving 3

    ? IIf(LookUp("inc rementOf","tblP FST","tblPFST.s erviceOf='1' And tblPFST.rankOf= 'CAPT'")>5,5+1, "N/A") is giving "N/A"

    What could I be doing incorrectly?

    Thanks

    Raghu Prabhu
    Attached Files
    Last edited by NeoPa; May 21 '12, 12:52 PM. Reason: Added mandatory [CODE] tags for you.
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi

    From you description abd DB shouldn't the Control Source be
    Code:
    =[increment]+1
    ??

    To use the DLookup() you would need to refer to the controls on the form any way (which you don't) but as you have the current increment value in the form why not just add one?

    Using either method would not actually increment the table data as it stands. Udating the table with this form would need a bit of code, usually in the form Open/Load or Unload/Close events, depending on when the update is required etc.

    HTH


    MTB
    Last edited by MikeTheBike; May 21 '12, 11:53 AM. Reason: More info

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32653

      #3
      Where is LookUp() defined? I only have DLookup() available in my system ;-)

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        If by data source you mean control source, then of course it won't update. It is no longer linked to a field in the table. You need to bind the control source to the field and do the update in an event.

        Comment

        • hrprabhu
          New Member
          • May 2010
          • 83

          #5
          Originally posted by hrprabhu
          I have attached a small database. In the "sFrmIncrements " there is a field named "newIncreme nt" I am trying to update the field but is not working. I don't know why.

          Code:
          IIf(LookUp("incrementOf","tblPFST","tblPFST.serviceOf='" & [serviceType] & "' And tblPFST.rankOf='" & [rank] & "'")>[increment],[increment]+1,"N/A")
          is the data source for the field.

          If I try it in the intermediate window it is working.

          ? IIf(LookUp("inc rementOf","tblP FST","tblPFST.s erviceOf='1' And tblPFST.rankOf= 'CAPT'")>2,3+1, "N/A") is giving 3

          ? IIf(LookUp("inc rementOf","tblP FST","tblPFST.s erviceOf='1' And tblPFST.rankOf= 'CAPT'")>5,5+1, "N/A") is giving "N/A"

          What could I be doing incorrectly?

          Thanks

          Raghu Prabhu
          Sorted it by way of 500 lines of code instead of one line
          Attached Files

          Comment

          Working...