PC Review


Reply
Thread Tools Rate Thread

Creating a look up field

 
 
Smithpr Bears
Guest
Posts: n/a
 
      27th Jul 2008
I have a file with post code data and want to be able to enter the name of
the town and have the correct post code displayed in a field.
 
Reply With Quote
 
 
 
 
Graham R Seach
Guest
Posts: n/a
 
      27th Jul 2008
The easiest way is to setup the combo's RowSource property to include not
nly the town name, but also the postcode, and then simply extract the
postcode when the town is selected.

Set the combo's Rowsource to:
SELECT TownName, Postcode
FROM tblPostcodes
ORDER BY TownName

Set the combo's ColumnCount property = 2
Set the combo's ColumnWidths property = "3cm;1cm" 'or as appropriate

Then add the following code:
Private Sub cboTownName_AfterUpdate()
If Not IsNull(me!cboTownName) Then
Me!txtPostcode = Nz(Me!cboTownName.Column(1), 0)
End If
End Sub

By the way, if the postcodes are listed in another database, link the table
in which they're stored.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

"Smithpr Bears" <Smithpr (E-Mail Removed)> wrote in message
news:05165FA6-3A1C-43FA-9005-(E-Mail Removed)...
>I have a file with post code data and want to be able to enter the name of
> the town and have the correct post code displayed in a field.


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Calculated Field in a Pivot Table for same field dza7 Microsoft Excel Programming 3 21st Oct 2009 11:22 PM
Pivot Table question: Creating a new field that calculates thedivision of one data field by another Mike C Microsoft Excel Discussion 4 13th Jul 2009 08:15 PM
Creating a new field based on the values of an existing field. =?Utf-8?B?UGV0ZXI=?= Microsoft Access Getting Started 4 21st Jul 2007 01:22 AM
Creating a field based on 2 characters from Field 1 and an auto nu =?Utf-8?B?TXNSZWVjZQ==?= Microsoft Access Database Table Design 1 26th Nov 2006 01:31 AM
Creating a multiselect field in a form to populate a single field in a table Conni Microsoft Access Forms 1 21st Sep 2004 05:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:59 PM.