Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2007
    Posts
    12

    Unanswered: A change in Focus

    CyberLynx gave me some code to use on one of my forms:

    Private Sub Form_Current()
    'If this is a new record then fire the
    'SetPermitField function.
    If Me.NewRecord = True Then
    Call SetPermitField
    'Set Focus onto the Project Date TextBox
    'when going into a new Record.
    Me.ProjectDate.SetFocus
    End If

    I changed the code to this:


    Private Sub Form_Current()
    'If this is a new record then fire the
    'SetPermitField function.
    If Me.NewRecord = True Then
    Call SetPermitField
    'Set Focus onto the Project Date TextBox
    'when going into a new Record.
    Me.StreetNr.SetFocus
    End If

    I get this error:

    Compile error:

    Method or data member not found.

    All I wanted to do was set the focus for a new record on the street number instead of the project date.

    Any Ideas?

    Thanks

    Sonnyboy

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    You don't have a field named StreetNr on the form. Look at the name property of each field on the form (not the source object name.) For example, you may have a field called StreetNr but it's name on the form is something else.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Sep 2007
    Posts
    12
    Actually I did have a textbox named "StreetNr" on the form. What I didn't think about or know, was that the change would not be retroactive. On the old records, the cursor moves to the position dictated by the old code, on the new record it moves to the new position. Wow! there are so many mines in the minefield. I learn something all the time.

    Thanks for your help
    Sonnyboy

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    As long as you learn something different each time, then you're making progress
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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