probleum in inserting empty records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • veer
    New Member
    • Jul 2007
    • 198

    #1

    probleum in inserting empty records

    Hi
    i have a mdb table in which i want to access the data from mdb table into new table i,e Operator but the condition is if the data in first row of column say "operator_c ode" is "alfred" . The name alfred is inserted into operator
    OK
    and when i move to the next row in the column i,e "operator_c ode"
    lets assume it is empty in that case the value of previous row i,e "alfred" must be inserted into the empty row
    i create a loop but it is not working for empty record
    [code=vb]
    For reccount = 1 To rsmaster.Record Count
    If Not IsNull rsmaster.Fields ("Yp1VOp") Then
    YpVcode = rsmaster.Fields ("Yp1VOp")
    squery = "insert into operator values( ' " & YpVcode & " ' )"
    dbmaster.Execut e (squery)
    Else
    squery = "insert into operator values( ' " & YpVcode & " ' )"
    dbmaster.Execut e (squery)

    End If
    rsmaster.MoveNe xt
    Next[/code]

    please give me help
    best regards
    varinder
    Last edited by debasisdas; Apr 17 '08, 10:31 AM. Reason: added code=vb tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Once you move to tthe next record how it will access the previous record. You need to store the previous record in a variable and check the next rerord. Continue this is a loop till the last record.

    Comment

    • veer
      New Member
      • Jul 2007
      • 198

      #3
      Hi
      i stored the value in a variable named "YpvCode"
      and i used this condition

      For reccount = 1 To rsmaster.Record Count
      If rsmaster.Fields ("Yp1VOp") <> "" Then
      YpVcode = rsmaster.Fields ("Yp1VOp")
      squery = "insert into operator values( ' " & YpVcode & " ' )"
      dbmaster.Execut e (squery)
      Else
      squery = "insert into operator values( ' " & YpVcode & " ' )"
      dbmaster.Execut e (squery)
      End If
      rsmaster.MoveNe xt
      Next

      but when the empty record came, the control is not moving on to else condition
      how is it possible
      please check the condition and give me suggestion






      Originally posted by debasisdas
      Once you move to tthe next record how it will access the previous record. You need to store the previous record in a variable and check the next rerord. Continue this is a loop till the last record.

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        Check if the record is empty or contains spaces.

        Comment

        • veer
          New Member
          • Jul 2007
          • 198

          #5
          Hi
          the record is empty there is not space because
          i am accessing mdb file
          the first row of column contain data"alfred"
          the 2nd row of column is empty and i want the data from first row of that column in 2nd row of column




          Originally posted by debasisdas
          Check if the record is empty or contains spaces.

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            Have you tried as suggested in post #2.

            Comment

            • veer
              New Member
              • Jul 2007
              • 198

              #7
              yes i tried it

              For icount =1 to rsmaster.record count
              If rsmaster.Fields ("Yp1VOp") <> "" Then
              YpVcode = rsmaster.Fields ("Yp1VOp") \\stored value in ypvcode
              squery = "insert into operator values( ' " & YpVcode & " ' )
              dbmaster.Execut e (squery)
              Else
              squery = "insert into operator values( ' " & YpVcode & " ' )"
              dbmaster.Execut e (squery)
              End If
              rsmaster.MoveNe xt
              Next

              In next step the field is empty i want the value from YpVCode in the empty field
              but when the empty field came it is not following
              rsmaster.Fields ("Yp1VOp") <> "" condtion but i want it jump and directly goto else condition


              Originally posted by debasisdas
              Have you tried as suggested in post #2.

              Comment

              • debasisdas
                Recognized Expert Expert
                • Dec 2006
                • 8119

                #8
                try like this

                YpVcode= iif(isnull(rsma ster.Fields("Yp 1VOp")),null,rs master.Fields(" Yp1VOp"))


                and since you are eecuting the same code why using IF....ELSE

                Comment

                Working...