Results 1 to 3 of 3

Thread: dlookup help

  1. #1
    Join Date
    Nov 2003
    Posts
    4

    Unanswered: dlookup help

    I'm trying to create a form that will consist of 10 fields. On field (1) ("JobID"), I want a user to have the ability to type in a job# (numeric) and have remaining 9 fields fill in the information related to what job# was inputed. I have been told that the best way to do this is with a combo box, but the data table is much to large for this. Thank you in advance for you help.....

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Okee doekee....try this

    Place a unbound textbox on your form (to be used for job number input) and then in the 'LostFocus' event place the following code:

    Code:
    '(all one line)
    Me.RecordSource = "SELECT * FROM myGreatBigTable WHERE (([myGreatBigTable]![Field1])=[Forms]![my10FieldForm]![MyJobNumberInputTextBox]));"
    
    Me.Requery
    OR try this:

    Make sure the Record Source property for your form is set to the Table containing the data you seek and the ten display fields in your form have their Control Source properties set to their respective table fields. Place a unbound textbox on your form (to be used for job number input - say called MyJobNumberInputTextBox) and then in the 'LostFocus' event place the following code:

    Code:
    Me.Filter = "[Field1of myTable] = '" & Me.MyJobNumberInputTextBox & "'"
    Me.FilterOn = True
    Me.Requery
    When the user tabs off the input text box the desired record(s) fills in.

    Now....rather than placing the code above into the LostFocus event of the job number input box, you may want to place it into the 'KeyDown' event instead so that everything fires when the [Enter] key is pressed (or what the heck...you might want it in both events). For example:

    Code:
    If KeyCode = vbKeyReturn Then 
       Me.Filter = "[Field1of myTable] = '" & Me.MyJobNumberInputTextBox & "'"
       Me.FilterOn = True
       Me.Requery
    End If
    Oh what the heck...Fill a combo box and place the code into the KeyDown event for that box (or or a dozen other different ways)

    I think you get the idea......
    Last edited by CyberLynx; 12-05-03 at 00:15.

  3. #3
    Join Date
    Dec 2003
    Posts
    18

    Re: dlookup help

    Hello.

    Try this. I think a combo box is still the way to go, however, you can type in a number and press return to display the corresponding record info. You don't always have to display the whole list to choose an item. Try also to set the 'limit to list' property to "yes" and the list size to 1.

    Hope this helps.

    Amadea

Posting Permissions

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