Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Location
    New York
    Posts
    4

    Unanswered: '#' in FieldName causing problem.

    Hi Everyone!

    Have a table wthe the field Part#. When I use it in a Form and attempt to use any of its events it identifies itself improperly. For instance if I want to use the AfterUpdate Event, it comes out the like this:
    Private Sub Part__AfterUpdate()
    Also cannot assign any values to its textbox (get an error in code).

    Any Ideas whats going on here!

  2. #2
    Join Date
    Apr 2004
    Posts
    110
    What exactly do you mean by 'does not identify itself properly'

    George Papadopoulos'

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    # is a wild card in Access and indicates a single numeral- or at least it does in a SQL statement using the like operator. Whather this is related or not, I don't know. However, as far as your form is concerned, the easiest thing to do is give your text box a different name to your field name

    e.g.
    Textbox name = txtPart
    Textbox control source = Part#

    your events will now read: txtPart_AfterUpdate etc..

    You may find a whole load of unexpected effects of using non alphanumeric symbols in your object names (and field values). For example, if I remember correctly #TableName in SQL server indicates a temporary table, or something like that. It may be an idea to avoid such use, and change any that you can. Also, please see below from access help:

    Guidelines for naming Visual Basic procedures, variables, and constants
    Names of procedures, variables, and constants in your Visual Basic for Applications code:

    Can be up to 255 characters long.


    Must begin with a letter.


    Can include letters, numbers, or underscore characters (_).


    Can't include punctuation characters or spaces.


    Can't be a Visual Basic keyword.

  4. #4
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    I had the same problem. I fixed it be renaming all of the fields in the table with that # in it. I also figured out how to get around it before I did that.

    To use any function with something named with the # key then you have to use the Part_ then the _AfterUpdate() or Part_ then _OnClick() Stuff like that. Always have to use the Part_ instead of the Part# because Part# doesnt work, but the Part_ will.

    If you need any more help tell me,
    JS

    Edit:

    Example if you wanted the Part# field to be disabled you would do the following.

    Code:
    Part_.Enabled = False
    To use an _AfterUpdate Event you would do the following.

    Code:
    Private Sub Part__AfterUpdate()
        'Your code here
    End Sub
    Of course all of that is only if you dont want to or cant change the # to ID or to NUM or something other than the special symbol.

    Hope this helps,
    JS

    Quote Originally Posted by TheAceMan1
    Hi Everyone!

    Have a table wthe the field Part#. When I use it in a Form and attempt to use any of its events it identifies itself improperly. For instance if I want to use the AfterUpdate Event, it comes out the like this:

    Also cannot assign any values to its textbox (get an error in code).

    Any Ideas whats going on here!
    Last edited by JSThePatriot; 05-06-04 at 10:45.
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

Posting Permissions

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