Results 1 to 11 of 11
  1. #1
    taholmes160 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Location
    Lester, Ohio
    Posts
    67

    filling in a dynamic label based on the selection in a combo box on the same form


    HI Folks:

    Im working on a section of my database where trains are scheduled. Due to the way things work, the trains are "created" in one form, and then scheduled in a different form. the creation form works great. Im trying to stretch my skills a little bit doing this scheduling form.

    The train to be scheduled is selected in a combo box, which is powered by a query that contains all the relevant info. (called QryTrains). Id like to have a dynamic label that changes based on the train selected for scheduling. The label should read "Departure from (and then have the name of the station drawn from query trains) and then have a combo box with time values in it -- the combo box is no issue at all, getting the form to read the value from the query and insert it in the label is a bit more of a problem. I suspect it needs a requery someplace, but I'm not sure where.

    I'd attach a copy, but for some reason the attachment manager keeps failing when I try to upload

    Thanks for the help

    TIM

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by taholmes160 View Post
    I'd attach a copy, but for some reason the attachment manager keeps failing when I try to upload
    Try Compacting and Repairing your db first and then ZIP it up before uploading.

  3. #3
    taholmes160 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Location
    Lester, Ohio
    Posts
    67

    Still giving me trouble

    @ruralguy -- thanks for the tip, unfortunately, Its still doing the same thing after compacting and repairing

    TIM

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    getting the form to read the value from the query and insert it in the label is a bit more of a problem
    in vba you would use something like

    me.lblcontrolname.caption="Departure From " & me!stationnamefield

    where you put this code depends how your app works - but suggest probably either the form load or current event

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    How large is the file after ZIPPING it up?

  6. #6
    taholmes160 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Location
    Lester, Ohio
    Posts
    67
    Hey Rural Guy:

    Its 4,993KB, so what 4.9 megs? not real big, is that too large?

  7. #7
    taholmes160 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Location
    Lester, Ohio
    Posts
    67
    Ajax:

    the form will be able to know were the departure is from once I choose the train in the combo box above, so where would that be?

    also, is lblcontrolname a real function, or do i need to supply that name? -- NOT a VB guy (doesnt mean I dont want to learn, but have exactly 0 experience with it)

    Thanks so much
    TIM

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by taholmes160 View Post
    Hey Rural Guy:

    Its 4,993KB, so what 4.9 megs? not real big, is that too large?
    Unfortunately, 2.0 MB is the limit.
    Did you include all of the fields you need in the RowSource of the ComboBox. If so it is easily accessible in the AfterUpdate event of the control.

  9. #9
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    is lblcontrolname a real function
    no its the name of your label control

    the form will be able to know were the departure is from once I choose the train in the combo box above, so where would that be?
    that would be the name of your combobox - from your description it needs to be the first column that is displayed. Typically this will be the second column (the first is usually the PK and is hidden). Columns are numbered from 0 for the first column so your code might be

    me.lblcontrolname.caption="Departure From " & me.comboboxname.column(1)

  10. #10
    taholmes160 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Location
    Lester, Ohio
    Posts
    67
    RuralGuy:

    Yes I did for the train ID combo box, all the values I need are there, Im having trouble getting the ones that I want from there to the label box which is the next line

    TIM

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The syntax to reference a column in a ComboBox is: Me!THENAMEOFYOURCOMBOBOX.Column(n)
    Where n is the column number starting at 1.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 24
    Last Post: 02-11-2014, 06:41 AM
  2. Replies: 3
    Last Post: 01-23-2014, 01:19 AM
  3. Replies: 1
    Last Post: 10-30-2012, 10:29 AM
  4. Replies: 1
    Last Post: 10-25-2012, 12:58 PM
  5. Replies: 1
    Last Post: 02-25-2011, 10:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums