Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2009

    Unanswered: Oat-so-simple but i dont have a clue

    K im going to sound really silly now but i just cant figure it out.

    I have a text box on my form called Quantity and it get its data automatically inputted from a combo box also on the form.

    I then have another text box called Quantity_In that the user inputs a number. this hasnt had any configuring at all

    Last but not least i have another text box called New Quantity which i have put a calculation in the control source in order to add the Quantity to the Quantity_In.

    Now you would of thought this is simple right, it would work...

    BUT!! ITS NOT! instead of adding the values its adding the number that the user inputs onto the end of the number that shows in Quantity. E.g. if the Quantity was 24 and the user added 2 it is showing in New Quantity as 242 instead of 26

    The calculation that is in New Quantity control source is: =[Quantity]+[Quantity_In]

    Please help!!

  2. #2
    Join Date
    Aug 2009
    Up Nort' Wi
    Dunno if you can do it with the =[] format, but, I'd try "=(cint([quantity]) + cint(quantity_in])"

    Worth a shot anyways,

    Sam, hth
    Good, fast, cheap...Pick 2.

  3. #3
    Join Date
    Jun 2004
    Arizona, USA
    Ahh... Rye did you do it?

    It would help you to remember that (unfortunately,) VB6/VBA can use the "+" operator for BOTH addition and String Concatenation. Unless you specifically tell it that the data in a text box is a number, (by using a conversion function like cInt) then, it could assume that you have text in a text box, of all places... Silly compiler. ***

    It's always a good idea to explicitly convert the contents of a textbox to the desired data type as needed, AND, it's a good idea to always use the dedicated string contatenation operator (&) to append one string to another.

    strNewText = "Concatenate one String" & " to " & "Another"
    *** Don't you just HATE it when a program assumes that you know what you're doing?
    Last edited by loquin; 11-25-09 at 17:39.
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert

  4. #4
    Join Date
    Dec 2004
    Madison, WI
    Quote Originally Posted by loquin View Post
    *** Don't you just HATE it when a program assumes that you know what you're doing?
    It's like you have to 'think' like Microsoft was thinking when they designed it. And MS can be so vague at times.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    I'd agree that using + and & for string concatenation is silly, in an ideal world they'd use a single character. however given the stated aim to merger VB & C# I don't see that happening. mind you it would be nice if all the languages used similar constructs. it would certainly help if like me you have to leap form development environment to development environment

    however I can understand why its doing what you are doing when using controls. the clue is in the name they are called 'Text Boxes', not number boxes.
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Feb 2004
    One Flump in One Place
    Sorry guys but I do like the + string concatenation operator. Note that even for string concatenation, & and + do not behave identically. As such, there are times when + is quite handy.
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Didn't I see this elsewhere?

    This actually goes back into the time before Visual Basic, before QuickBasic 4.5/QBasic, when everything had to have a declared data type! As the OP noted in the other forum, using subtraction/division/multiplication works without a problem, without the datatype be declared thru formatting or assigning of a datatype. That's because these operations can only be performed on numeric data types! But use of the plus sign can be taken either as addition (if a numeric data type is involved) or as concatenation (if a text data type is involved) and so Access needs guidance. Left alone, it does, indeed, assume that a textbox contains text! So, in order to an unbound controls to actually be added, you have to, in some manner, left Access know what type of data they are. You can use CInt() as above, or Val(), as suggested elsewhere, or format the textbox as a number. But you have to give Access a clue as to what kind of data it's dealing with!
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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