Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2004
    Location
    Inverurie
    Posts
    628

    Unanswered: Dressing lookup text boxes

    I have a series of text boxes that look up specific information based on a users selection in two combo boxes.

    When the form is opened for the first time all of the text boxes are showing #Error in them. Is there any way that i can get them to show as empty until the user makes a selection in the appropriate combo box?

    Thanks in advance for any help provided.

  2. #2
    Join Date
    Aug 2004
    Location
    Steamboat Springs, CO
    Posts
    37
    There may be other ways to do this, but what I've done in the past in situations like this is add this code to the after update of the combobox and delete the source from you text box.

    me!yourtextbox.RowSource = "Nameofyoursource"

    This way your text box is unbound until the combobox is updated.

    Hope this Helps.

    Jeremy Brooks
    PSIA-RM

  3. #3
    Join Date
    Jul 2004
    Location
    Inverurie
    Posts
    628
    ok, let's see if i understand this correctly...

    Because im using a DLookup string (typed straight into the textbox in design mode), if i changed this to the after update event, i could basically get my combo boxes to put a "z" in for arguments sake, and it'll still overwrite it with the desired value?

    for example, on the combo box change event:

    Forms!front_wheel_build.dl.controlsource =DLookUp("dl","hubs","[hubID]=" & [Forms]![front_wheel_build]![combo45])

    from there, i just put the other relevant text boxes that are populated by this control in?
    Last edited by cruickshanks; 10-06-04 at 11:39.

  4. #4
    Join Date
    Jul 2004
    Location
    Inverurie
    Posts
    628
    I've tried the following:

    Me!dl.ControlSource = "=DLookUp("dl","hubs","[hubID]=" & [Forms]![front_wheel_build]![Combo45])"

    and i get an error at the dl just after the DLookup part of the statement stating "Expected end of statement". What should i do to correct this??

  5. #5
    Join Date
    Sep 2004
    Location
    Kuala Lumpur
    Posts
    60
    Check what meremyb said again:

    "...add this code to the after update of the *combobox* and *delete* the source from you *text box*."

  6. #6
    Join Date
    Aug 2004
    Location
    Steamboat Springs, CO
    Posts
    37
    Sorry I didn't get to this earlier. It may be that you'll have to use ' instead of " inside the outer quotes. Try:

    Me!dl.ControlSource = "=DLookUp('dl','hubs','[hubID]=' & [Forms]![front_wheel_build]![Combo45])"

    or you could set the string as a variable

    Dim sourcevar as string
    sourcevar = "=DLookUp('dl','hubs','[hubID]=' & [Forms]![front_wheel_build]![Combo45])"
    Me!dl.ControlSource = sourcevar

    Hope this Helps

    Jeremy Brooks

  7. #7
    Join Date
    Jul 2004
    Location
    Inverurie
    Posts
    628
    That was a great help, thanks a lot.

    I found a really basic way to do this late last night (just thought of it at that point). It was to make the text box fore colour white, and then use Me!textbox.Forecolor = 0 on the combo box AfterUpdate event.

    But i feel that this is a crude way to do it, but it works. I'll more than likely just be switching over to the method that you've told me about.

  8. #8
    Join Date
    Jun 2002
    Location
    Saudi Arabia / Philippines
    Posts
    126
    Hi

    I haven't tried this but may I suggest you try wrapping the DLookUp inside an IIf function that tests the value in the Combo Box.
    Rod

    fe_rod@hotmail.com

  9. #9
    Join Date
    Jul 2004
    Location
    Inverurie
    Posts
    628
    That would probably work.

    I'll try it out on a copy of the database and let you know how it got on.

Posting Permissions

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