Results 1 to 7 of 7
  1. #1
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481

    DLookup Function for City/Region/Country?


    Hi,

    I have three fields on a Customers form "City", "Region" & "Country" where "City" field is sourced from a table "tblecity" which have the following fields:


    tblecity

    CityID
    CityName
    Region
    Country

    to reduce the entry work, i am looking to code DLookup function where i just select the city and other two fields must be populated itself.


    please advise.


    Zee

  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,847
    What exactly is the question?
    Have you considered a combo box and using the On Change Event?

    If you do a DLookup on City, how do you differentiate same city name in different regions or Country?

    Kingston Ontario Canada
    Kingston New York USA
    Kingston Pennsylvania USA
    Kingston New Hampshire USA

  3. #3
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Sir,

    Yes had a combo box which supplied data from Tblecity.

    Data is stores like:

    Riyadh Central Region Saudi Arabia
    Dammam West Region Saudi Arabia


    please advise needful

    thanks

    zee

  4. #4
    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,847
    Do you have a question?
    Have you considered a combo box and using the On Change Event?

  5. #5
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Here is an easier alternative.
    I am assuming CityId is your primary key. Create a combo box having rowsource "SELECT CityID,CityName,Region,Country from tblCity ;" and 4 columns having widths 0cm;4cm;0cm;0cm so that only Cityname is visible. Then you can use YourComboboxName.Column(2) and YourComboboxName.Column(3) as controlsource for controls(unbound) used to display Region and Country respectively.

  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,847

  7. #7
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    orange,
    The only difference is no VBA code is required to populate the region and country fields. Please correct me if I am wrong as I am not an access expert and still on a learning curve.

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

Similar Threads

  1. Dlookup Function
    By MarkHenderson in forum Queries
    Replies: 1
    Last Post: 11-19-2012, 03:00 PM
  2. Replies: 2
    Last Post: 11-17-2012, 10:13 PM
  3. DLOOKUP function
    By tariq1 in forum Programming
    Replies: 5
    Last Post: 07-17-2012, 04:22 PM
  4. DlookUp Function.
    By cap.zadi in forum Forms
    Replies: 11
    Last Post: 09-22-2011, 12:56 PM
  5. Need Help for Dlookup function
    By wasim_sono in forum Programming
    Replies: 5
    Last Post: 01-04-2006, 08:18 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