+ Reply to Thread
Results 1 to 8 of 8

Combobox to fill textbox with one of 3 choices

  1. #1
    Registered User
    Join Date
    08-05-2009
    Location
    Ballarat Australia
    MS-Off Ver
    Excel 2007
    Posts
    65

    Combobox to fill textbox with one of 3 choices

    hi all,

    I have a form that I use to track tonnes of rock delivered to jobs

    deliveries are by truck & trailer combination's

    when i select a truck number from the combobox it fills a textbox with the combined tare weight of the truck & trailer

    Example Truck = 10.00 tonnes Trailer = 5.20 tonnes combined tare = 15.20 tonnes

    90% of the deliveries are by truck & trailer however on occasion I do have to weigh the truck or trailers by themselves

    I thought of using checkboxs to select one or the other but am unsure if or how this would work. Very limited knowledge

    please have a look at the file attached


    thanks for looking

    regards nighttrainrex
    Last edited by nighttrainrex; 01-19-2012 at 04:33 PM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Combobox to fill textbox with one of 3 choices

    one way would be

    Please Login or Register  to view this content.
    but it could be refined so that if you click the checkboxes the value adjusts
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    08-05-2009
    Location
    Ballarat Australia
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Combobox to fill textbox with one of 3 choices

    Hi Pike

    Thanks for that,

    Using the code that you provided, I found that if the I select a truck number before clicking the check box I get 0 in the text box

    However if I select both the check box then the truck number I get the combined value & if I select on or the other check boxes I get the truck or trailer weight.

    while this is correct it seems to round the numbers -example truck number test truck = 10.20 + trailer = 5.10 = combined 15.30 but it enters them as truck = 10 + trailer = 5 = combined 15

    is there a way around this?

    Also I have defaulted the check boxes to be selected so that when I select a truck the combined weight comes up is it possible to have it so that I can select the truck 1st then un-check say the trailer check box & have the value change?

    I have attached the changed file

    thanks again

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Combobox to fill textbox with one of 3 choices

    Yep the variable declare as double hold different info

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-05-2009
    Location
    Ballarat Australia
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Combobox to fill textbox with one of 3 choices

    Pike,

    Works well except for the following issue,

    I select truck number, then both check boxes & fill in the rest of the details, click on the ok button, data is written to worksheet, but I get a runtime error 13 "Type Mismatch" and the following line of code highlighted (just the text in red) & the check box for has a check in it,this error happens if both check boxes are selected or if I select a check box before selecting truck number, using one at a time causes no issues.

    Trailer_Value = Worksheets("Trucks").Range("C" & CmbRego.ListIndex + 2)

    I get the same fault if I choose a check box before selecting a truck number


    HTML Code: 
    Last edited by nighttrainrex; 01-18-2012 at 10:47 PM.

  6. #6
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Combobox to fill textbox with one of 3 choices

    Ive tested this ...
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-05-2009
    Location
    Ballarat Australia
    MS-Off Ver
    Excel 2007
    Posts
    65

    Thumbs up Re: Combobox to fill textbox with one of 3 choices

    Pike,

    that works fine, I will now save a 2nd copy so ! can have a play & see what I can learn.

    thank you for your help.

    your time is appreciated

    regards nighttrainrex

  8. #8
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Combobox to fill textbox with one of 3 choices

    your welcome

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1