Results 1 to 3 of 3
  1. #1
    Cottonshirt is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Feb 2018
    Posts
    116

    go to next record, OR move focus

    I have a form that has two endpoints. the user needs to enter a number in either of two boxes, payment or receipt.

    the two boxes are one after the other on the form, so preferred behaviour would be:

    in the payment box
    on exit: If ([paymt] <>0, go to next record, otherwise cycle to receipt)

    in the receipt box
    on exit: go to next record

    so I wrote the following:

    Code:
    Private Sub paymt_Exit(Cancel As Integer)
    =IIf([paymt]<>0, DoCmd.GoToRecord , , acNext, Forms![frm_cost_reconciliation]![receipt].SetFocus)
    End Sub
    but this returns the following error message:

    Expected: line number or label or statement or end of statement


    can anyone tell me what I'm doing wrong,


    thank you for your time,




    Cottonshirt

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Should be using If Then Else not IIf() function.
    Code:
    Private Sub paymt_Exit(Cancel As Integer)
    If Me.paymt <> 0 Then 
        DoCmd.GoToRecord , , acNext
    Else
        Forms![frm_cost_reconciliation]![receipt].SetFocus
    End If
    End Sub
    So for each record either Payment or Receipt field will be empty (or default to 0)?

    Alternative (more normalized) is to have one field for Amount and another field to identify transaction type (Payment, Receipt).
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Cottonshirt is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Feb 2018
    Posts
    116
    Alternative (more normalized) is to have one field for Amount and another field to identify transaction type (Payment, Receipt).
    I changed it to this. it meant having another table for payment types but the form was simpler both to create and to use.


    thanks for your help.


    Cottonshirt

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

Similar Threads

  1. WHAT! Can't move the focus
    By GraeagleBill in forum Programming
    Replies: 7
    Last Post: 08-18-2016, 11:13 PM
  2. Runtime error 2110, cannot move focus to control
    By sanderson in forum Programming
    Replies: 7
    Last Post: 11-17-2015, 08:00 AM
  3. Replies: 3
    Last Post: 12-11-2014, 11:26 AM
  4. Replies: 4
    Last Post: 12-02-2012, 03:14 PM
  5. Move Focus From Subform To Main Form
    By burrina in forum Forms
    Replies: 2
    Last Post: 11-18-2012, 03:09 AM

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