Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Compile Error (2000)

    Hi,

    I am trying to use the SetFocus command to try and get the cursor to appear in the field:

    CDRL Ref

    When l enter a new record. For some reason l am getting an error.
    See attachment.

    Any help would be appreciated.
    Justin.
    Attached Images Attached Images

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

    Re: Compile Error (2000)

    If a control name contains a space, VBA gets confused, because it sees the parts as separate items, which are not recognized, of course. To avoid this confusion, enclose such names in square brackets:

    [CDRL Ref].SetFocus

    It would be even better to avoid the use of spaces, punctuation and unusual characters in the names of tables, fields, controls, etc.

  3. #3
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile Error (2000)

    Thanks for that.

    I now appear to be getting an error which l don't know the cause of.
    See attachment.

    Justin.
    Attached Images Attached Images

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

    Re: Compile Error (2000)

    When does this error occur? When you open the form, or when you click a button, or what?

  5. #5
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile Error (2000)

    This occurs when l click on the "Add Record" button.

    Justin.

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

    Re: Compile Error (2000)

    Assuming that the "Add Record" button is the same as the Command24 button referred to in your first post in this thread, check carefully that CDRL Ref is the exact name of the control on your form:
    - Open the form in design view.
    - Click on the control you want to set focus to.
    - Activate the Other tab of the Properties window.
    - Note the name as displayed in the Name property.

  7. #7
    5 Star Lounger
    Join Date
    Mar 2004
    Posts
    924
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile Error (2000)

    I have checked this and the name is the same.
    Any further ideas / suggestions?

    Justin.

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

    Re: Compile Error (2000)

    Not without seeing the database.

Posting Permissions

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