Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Change Records on Form (2003 and XP)

    I have the following code to update the recordset of a form. However when it finishes running all the controls that are bound to the recordset have "###" in them. The data can be edited manually, and when I close and open the form the updated data appears. If after running the code I try to refresh the form manually the refresh command on the record menu is grayed out.
    Any ideas?
    Thanks

    this is the code:

    Private Sub cmdCheckOff_Click()
    Dim intRunSum As Integer
    Dim rstMe As dao.Recordset
    Dim intBalance As Integer

    intRunSum = 0

    Set rstMe = Me.Recordset
    rstMe.MoveFirst
    Do

    With rstMe
    .Edit
    .Fields("ynKablanPAid") = -1
    .Update
    .MoveNext
    End With
    intRunSum = intRunSum + Me.curMatzevaPriceActual
    Loop Until intRunSum > Me.curAmount
    Set Me.Recordset = rstMe
    rstMe.Close
    Set rstMe = Nothing

    intBalance = Me.curAmount - intRunSum

    Call MsgBox(" the balance is" & intBalance, vbExclamation, "balance")

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change Records on Form (2003 and XP)

    Try removing the line

    Set Me.Recordset = rstMe

    and replacing it with

    Me.Requery

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Change Records on Form (2003 and XP)

    I tried refresh and requery and they did not help.
    This also happens on another similar code that I run also on this form.
    Thanks

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change Records on Form (2003 and XP)

    Ah, you don't need the requery, but you should also remove the line rstMe.Close. Since rstMe is the recordset of the form, you shouldn't close it!

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Change Records on Form (2003 and XP)

    that makes a lot of sense!
    Of course, like a good boy I ALWAYS release variables. This when you should not
    Thanks Again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •