General discussion

Locked

Combo Box using Access2000

By manjeet ·
I am creating a form using Access2000, my problem is I have a table called Postcodes and it has 2 fields Town and Postcodes.

what I would like in my form is when I select town(combo box)in my form field I would like the corresponding postcode toappear in the postcode field in my form.

Can some one help me please....

Thank you

Manjeet

This conversation is currently closed to new comments.

9 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Combo Box using Access2000

by donq In reply to Combo Box using Access200 ...

I do this often by basing my Form's Data Source on a dynaset query that deliveres every value for any record I need (including Town and Postcode). I then populate the "Town" field from a Combo box that has its "Row Source" property set to an SQL statement that delivers all of my form query options and its related Postcode. I then set the Postcode field on the form so it does NOT receive focus and instruct the combo boxes After Update event to requery the form.

Hope this helps - the secret is basing everything on queries that can be executed dynamically (or on-the-fly).

Collapse -

Combo Box using Access2000

by manjeet In reply to Combo Box using Access200 ...

The question was auto-closed by TechRepublic

Collapse -

Combo Box using Access2000

by RichTee In reply to Combo Box using Access200 ...

A simple way to resolve your problem would be to change the ?postcode? field on your Form from a Text box to a Combo box. (in design view, right click, change to, select combo box). This will also eliminate the need for the special combo to make the selection.

In Properties:
Data Tab:
Set the Row Source Type to : Table/Query
Set the Row Source to: Select he table containing the town and postcodes from the drop down
Set Bound Column to: 1 or 2 depending which field is the postcode
Format Tab:
Set Column Count to: 2 (This will show both fields in your drop down)

Hope this helps. You can contact me if you need some more info on how to do this.

Rich

Collapse -

Combo Box using Access2000

by manjeet In reply to Combo Box using Access200 ...

The question was auto-closed by TechRepublic

Collapse -

Combo Box using Access2000

by Bob Sellman In reply to Combo Box using Access200 ...

Set the source for the combo box to select the town and the postcode. Set the displayed column widths for the combo box to 1" (or whatever is appropriate for the town) and 0" (1";0"), unless you also want to display the postcode with the town.

For the After update property of the combo box, include the following code:

me.Postcode = me.cboTown.column(1)

This will put the postcode value from the selected row in the combo drop down list into the postcode field. (Note that the column numbers start at 0 for this statement, even though on the properties you would refer to this column as column 2!)

You might also set the locked property of the postcode to true so the user could not change it.

If the correct postcode is not displayed when you go to a different record, set the on current property of the form to include the following code:

me.cboTown.requery
me.cboPostcode = me.cboTown.Column(1)

Collapse -

Combo Box using Access2000

by manjeet In reply to Combo Box using Access200 ...

The question was auto-closed by TechRepublic

Collapse -

Combo Box using Access2000

by zerocool In reply to Combo Box using Access200 ...

Just tell the postcodes caption to epual that.

Collapse -

Combo Box using Access2000

by manjeet In reply to Combo Box using Access200 ...

The question was auto-closed by TechRepublic

Collapse -

Combo Box using Access2000

by manjeet In reply to Combo Box using Access200 ...

This question was auto closed due to inactivity

Back to Web Development Forum
9 total posts (Page 1 of 1)  

Related Discussions

Related Forums