Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2006
    Posts
    4

    Angry Unanswered: Access textboxes

    I have textboxes which in the 'view' mode show #name!
    The 'control source' properties is set for the table 'Customers' and the field for an customers ID.
    I am missing something, but am not sure what!
    I checked the site and found this:
    The Control Source property of the textbox should be EITHER the name
    of a field in the Form's Recordsource query; OR an expression in its
    own right, preceded by an equals sign, e.g.

    =[ThisField] + [ThatField];

    OR a Domain Function call to look up the value from a query:

    =DLookUp("[ResultField]", "[QueryName]", "optional criteria string")

    My guess is that you're just putting the name of the query, or
    queryname.fieldname, in the control source: that will NOT work.

    Does this "=[this field]+[that field];" line of code go into the Control Source?
    Or is <this ...> represent the name of my field out of the table?

    If I leave the field 'unbound' the default string will appear. But I am not sure my instructor will accept it.

    Thanks, kevomac12

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    What's with the semi colon?

    Also, is the name of the CONTROL the same as one of the fields you're referencing? that will cause a #NAME error as well.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jan 2006
    Posts
    4
    The semi colon was partof a thread I found on the forum, a syntax error occurs if the semi-colon is used in the control source field!
    My textbox name is 'txt_wholesalerID', the field in the table is named 'WholesalerNumber'!

    Kevin

  4. #4
    Join Date
    Jan 2006
    Posts
    4

    Angry Semi-colon

    Teddy, the semi-colon causes a syntax error in the 'control source'. I found a thread posted by another person, that suggested using =[field name];
    My textbox is named "txt_wholesalerID", the field from the table is named "WholesalerNumber"! So is there a naming contention?

    Kevin

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    a semi colon is used as a line terminator in sevral languages (including C, Java, PHP, amongst others, not to mention SQL) so its highly likely that the semi colon is a hangover from some other langauage
    what happens if you remove the semi colon

    How did this control appear on your form, did you insert it or did you use a wizard. As teddy says you will have a problem if it has the same name as the value you are trying to assign to it.
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Jul 2004
    Location
    Southampton, UK
    Posts
    368
    Hi Kevin
    I wonder if some explanation might help. Sorry if it's over simplified.

    You have a form. Normally the form is linked to a record source. This is set in the Record Source property in the form properties. The record source is typically the name of a query or the name of a table. Check that your record source is set to your query or table. You can only select one record source. You can only include fields in your form that are in your record source.

    On the form there are text boxes (amongst other things). These text boxes are normally bound to the specific fields in your record source. You do this by entering the name of the field from the record source in the Control Source property for each text box. You dont need anything other than the name (no equals, semicolons, square brackets or anything). As I said in your other thread, rather than typing it in you can use the drop down list for the control source. This will list all the fields that are in your record source. Its worth using this as it ensures that your required field exists in your record source and that you spell it correctly. Select the one you expect to see in the text box. If you cant find the one you are looking for then you have a problem.

    Hth
    Chris

  7. #7
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by kevomac12
    The semi colon was partof a thread I found on the forum, a syntax error occurs if the semi-colon is used in the control source field!
    My textbox name is 'txt_wholesalerID', the field in the table is named 'WholesalerNumber'!

    Kevin

    What's the second field?


    This SHOULD work. Don't use the semi colon. Also, check your datatypes to make sure you're applying the proper operator.

    =[txt_wholesalerID] + [your_other_numeric_field_here]
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  8. #8
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Adding 2 fields

    The best method I can think of that you might want to consider is this:

    1. Make sure the control source of your field is the name of the field in the table (don't do any additions for the control source on this field unless you don't want to store the total value.)
    2. In the after_update events of the 2 fields you want to put in this code (where the field called txtTotals is the field holding the total value):

    txt1_AfterUpdate()
    if not isnull(me!txt1) then
    me!txtTotals = me!txt1 + me!txt2
    end if

    txt2_AfterUpdate()
    if not isnull(me!txt2) then
    me!txtTotals = me!txt1 + me!txt2
    end if

    If you don't care about storing the total value, then you can do this:
    1. On the control source of txtTotals, enter this:
    =[txt1] + [txt2]
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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