Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Posts
    4

    Question Unanswered: Mysterious Bug - Go to the last record automatically

    Dear Sir or Madam,

    Good afternoon. Someone said that the computer moves the last (old)record down and the new record up in the subform after the amount is validated. The mouse pointer went automatically to the last record. I can't figured out why. Can you look at the code below, please?

    Private Sub Amount_AfterUpdate()

    On Error Resume Next

    Dim RecordIdentifer As Integer

    RecordIdentifer = CurrentRecord

    If IsRxAcctStrDeptOK() Then

    'The record is okay!

    Forms![Rx Cash Receipts entry Mainform].Recalc

    DoCmd.GoToRecord , , acGoTo, RecordIdentifer
    DoCmd.GoToControl "Memo"

    Else

    'Incorrect combination of account, store, and department

    MsgBox "Incorrect combination of account, store, and department", 16, "ERROR"

    [Amount] = 0
    Forms![Rx Cash Receipts entry Mainform].Recalc
    DoCmd.GoToRecord , , acGoTo, RecordIdentifer
    DoCmd.GoToControl "Account"


    End If


    End Sub

    Please let me know what's the problem.

    Thanks,

    Ryan

  2. #2
    Join Date
    Oct 2002
    Location
    Rochester, NY
    Posts
    84

    Re: Mysterious Bug - Go to the last record automatically

    Originally posted by AccessFan
    Dear Sir or Madam,

    Good afternoon. Someone said that the computer moves the last (old)record down and the new record up in the subform after the amount is validated. The mouse pointer went automatically to the last record. I can't figured out why. Can you look at the code below, please?

    Private Sub Amount_AfterUpdate()

    On Error Resume Next

    Dim RecordIdentifer As Integer

    RecordIdentifer = CurrentRecord

    If IsRxAcctStrDeptOK() Then

    'The record is okay!

    Forms![Rx Cash Receipts entry Mainform].Recalc

    DoCmd.GoToRecord , , acGoTo, RecordIdentifer
    DoCmd.GoToControl "Memo"

    Else

    'Incorrect combination of account, store, and department

    MsgBox "Incorrect combination of account, store, and department", 16, "ERROR"

    [Amount] = 0
    Forms![Rx Cash Receipts entry Mainform].Recalc
    DoCmd.GoToRecord , , acGoTo, RecordIdentifer
    DoCmd.GoToControl "Account"


    End If


    End Sub

    Please let me know what's the problem.

    Thanks,

    Ryan
    I have some questions for you:
    1) What exactly does the function IsRxAcctStrDeptOK() do? You do not have the code in your post.

    2) What updates the variable RecordIdentifer?

    My guess is that somewhere else in your code you are moving to the next record. You intend to do this so you can perform a data quality check and that is good. You should have all code for navigating your records inside of the Amount_AfterUpdate subroutine though. If you need a specific record displayed after the subroutine is done performing the validation, you should specify it there too. It looks like you're navigating through all of your records and then returning control to the calling routine from the form. This will leave you on the last record.
    Regards,
    Terry

  3. #3
    Join Date
    Nov 2002
    Posts
    4

    Re: Mysterious Bug - Go to the last record automatically

    Originally posted by spraguetr
    I have some questions for you:
    1) What exactly does the function IsRxAcctStrDeptOK() do? You do not have the code in your post.

    2) What updates the variable RecordIdentifer?

    My guess is that somewhere else in your code you are moving to the next record. You intend to do this so you can perform a data quality check and that is good. You should have all code for navigating your records inside of the Amount_AfterUpdate subroutine though. If you need a specific record displayed after the subroutine is done performing the validation, you should specify it there too. It looks like you're navigating through all of your records and then returning control to the calling routine from the form. This will leave you on the last record.
    Dear Terry,

    Thanks so much for trying to help me. I just figured out the answer for this problem. I added the auto numbering field to go to the last current record. It works now.

    Have a great day!

    Smile,

    Ryan

Posting Permissions

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