Results 1 to 8 of 8
  1. #1
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194

    Creating a search listbox and taking that value to populate text field

    Hey again ppl!

    My brain is blowng up with all the stuff im learning this week!



    So Im looking to learn a... procedure that I see HEAPS. I dont really have a good use for it right now but i have an example of how you use it. Its very common.

    Lets say i have
    Table [Customer]
    with {LastName} {Address} {SuburbID}

    and table [Suburbs]
    with {SuburbID}, {SuburbName} and {Postcode} in it

    I have made a form based on [Customer] and i have an unbound txt box.

    I currently can use that txtbox... [txtSuburbName] to generate a list of suburbs with that spelling (eg. lee brings up Leeming adn other Lee words.)

    I can get that part working.

    I can also get double clicking the suburb in the list box I want to use to allocate its [SuburbID] field to the [SuburbID] field on the form page.

    so now i have a search box which works and it finds the suburbID i need, but i want THAT box to show the suburb of the customer if they already have it entered...

    So i want it to be a bound search box ...?

    Maybe making the default value a dlookup function??

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    ??
    so now i have a search box which works and it finds the suburbID i need, but i want THAT box to show the suburb of the customer if they already have it entered...
    ???

    You want to find and display suburb name and existing Customers based on suburbID???

    Perhaps this link will help

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    When I build search forms I will have combos, text boxes, etc. as user input. Like you are doing, this will retrieve Primary Keys. What I will do is use these primary keys within a WHERE clause or as Filter criteria for a bound form. An event like a Button Click would open a second form that is bound, using the ID's (PK values) as criteria.

  4. #4
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    k, i was 100% NOT clear. Sorry it was really late and apparently my brain had turned off.
    Below is hopefully a better written question.

    -I'm not building a search form, but rather a separate listbox form

    So:
    You go onto form [customer] and input a new customer who's details are all on that customers table however when you get to SUBURB (as this is something i have in [Suburbs] table) I could do two things:

    1. Create a combo box that as you start writing it finds the suburb. It has a hidden primary key so it is now saying "Leeming | 6163" as the suburb and postcode.
    This WORKS, but number 2 is the thing i want to learn to do, as it is currently on an access program i use that someone else made and i like the idea

    2. have a textbox that you type a few letters then press enter. This brings up a listbox with a filtered list of suburbs starting with that text.
    - you then double click the one you want and it adds it as your suburb in the text bx you just used to search with.
    - I can do this however if the textbox is unbound and thus you search from it when you reopen the customer it wont be written there..

    OMG this is hard to explain when i see it all the time.

    Let me do some screen shots to show what i mean

  5. #5
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    Click image for larger version. 

Name:	Untitled-2.jpg 
Views:	20 
Size:	62.3 KB 
ID:	21117So this is what i want to do.
    If the suburb is just another text field on the [customer] table then sure, i can do this easily. But as suburb is listed as [SuburbID] I dont know what to do.

    I CAN make the listbox save the [SuburbID] to the record, however THEN the actual suburb text box is going to be blank as it is unbound...!!

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    You type "al" in the suburb of Customer form and it returns/presents "gamma"????

    You may find some info here
    or here.

  7. #7
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    lol ok sorry must have clicked when i was copying the page.

    The point is that it brings up a list, then it populates the field it was sitting in... but i cant figure out how to do this unless the textbox in the form is actually a field in that very table, rather than a field in a related table

    eg. if i had
    [customers]
    -name
    -address
    -suburb
    -postcode
    Sure, it is relatively easy. Type in suburb, searches listbox, allocates text "suburbname" from the listbox into [suburb]

    But what i have is

    [Customers]
    -name
    -address
    -suburbID ->Linked to [suburb]table.

    So if i had

    [customers]
    -name
    -address
    [SuburbID] (invisible)
    -SuburbName
    -SuburbPostcode

    These 2 bottom ones are bound to the ID and thus i cant use thm as a search field can i??

  8. #8
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    Wooo figured it out.

    Pretty much i now have a txtbox with default value "dlookup suburbID"
    I can then CHANGE that text to a search text, which opens up a listbox based on the text i put in.
    Then i double click on the listbox answer and it will save my new SuburbID as the one from the list as well as replaces the text is the txtbox with the selected list answer.

    This means its like a bound box... which is unbound lol?

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

Similar Threads

  1. Replies: 5
    Last Post: 01-24-2015, 11:49 AM
  2. Replies: 1
    Last Post: 08-07-2013, 02:43 PM
  3. Replies: 7
    Last Post: 02-01-2013, 02:58 PM
  4. Replies: 19
    Last Post: 11-01-2012, 08:03 AM
  5. Replies: 7
    Last Post: 08-08-2012, 03:28 PM

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