Results 1 to 2 of 2
  1. #1
    rd.prasanna is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    25

    Change Event not working for all the records of the Table.

    Hi All,

    Need clarification,
    Actually I have a form where i have multiple textbox fields with the data type is date and the same is associated with a table.

    but my concern is when u make chanegs in the 1st date field 2nd txtbox should calculate the second date (Eg: date2=date1+10)

    when i did it using change event for the 1st txtbox its working fine with only 1st record of the database, when i move to the next record the same codes not working, why is it so..

    below is the code what im using:

    Private Sub FC1_Change()
    Set db = CurrentDb
    Set rs = db.OpenRecordset("tbl_Trans", dbOpenDynaset)
    Pos = rs.AbsolutePosition
    MsgBox Pos
    Me.Dirty = False
    For i = 2 To 8
    rs.Edit
    rs.Fields("FC" & i) = rs.Fields("FC" & i - 1) + rs.Fields("Pln" & i) - rs.Fields("Pln" & i - 1)
    rs.Update
    Next i
    For i = 2 To 8
    If Weekday(rs.Fields("FC" & i), 2) = 6 Then
    rs.Edit
    rs.Fields("FC" & i) = rs.Fields("FC" & i) + 2
    rs.Update


    ElseIf Weekday(rs.Fields("FC" & i), 2) = 7 Then
    rs.Edit
    rs.Fields("FC" & i) = rs.Fields("FC" & i) + 1
    rs.Update
    End If
    Next i
    Set rs = Nothing
    Set db = Nothing
    End Sub

    Kindly do the needful.

    Regards,
    Prasanna R.D

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    There are three things that stand out in your post.

    1) Why are you using the change event? Every time the user types a character, the event fires. Maybe an afterupdate would be better

    2) Why are you attempting to store a calculated field in a table? Sometimes it is not a bad idea. Most the time it is a bad idea. usually calculations change as time goes by. So, rather than updating a table every time a user looks at a given field, you can just run the calculation in an unbound textbox. No need for the extra step of updating.

    3) Your code makes absolutely no sense to me.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. On Change event in Text Boc
    By quicova in forum Programming
    Replies: 2
    Last Post: 09-12-2013, 01:27 PM
  2. Recurring Change Event Erroe
    By dccjr in forum Programming
    Replies: 2
    Last Post: 02-18-2013, 08:26 PM
  3. Change Password field in Table not working
    By bongazi in forum Programming
    Replies: 4
    Last Post: 05-18-2011, 04:33 PM
  4. Trying to fire event on record change
    By danielhowden in forum Forms
    Replies: 3
    Last Post: 05-13-2011, 06:30 AM
  5. Any change of focus on form Event?
    By trb5016 in forum Forms
    Replies: 1
    Last Post: 02-11-2011, 08:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums