Autofiull Data based on Combo Box

kerrydunk

New member
Local time
Today, 09:03
Joined
Aug 8, 2013
Messages
6
Hi guys
I have a combo box that autofills a text box, this has duplicate values and I want to fill the text box based on the selection of the combo box.

Let me explain:
The combobox is Suburb, the text box is for Postcode, the data has multiple matches for example FRANKLIN has a postcode match of 2913 in ACT and also 7113 in TAS.

From the combo box I select the record that matches 7113 but 2913 enters into the text box.

This is my code:
In Row source of the combo box I have - SELECT [Australian Postcodes].Locality, [Australian Postcodes].Pcode, [Australian Postcodes].State FROM [Australian Postcodes];

In Event on change I have -
Private Sub Suburb_Change()
Me.Postcode = Me.Suburb.Column(1)
End Sub

Can someone please let me know how to change this to be based on the selected record from the combo box?

Hopefully this is an easy fix :-)
Many thanks
Kerry
 
I am still hoping for an answer on this one if there is anyone out there that can help me?
Thanks
Kerry
 
Hi Kerrydunk

The ComboBox has to have this in the event - in design view > Event tab, which you get to it by selecting the "Property Sheet" in Design tab.
This needs to be in the event "AfterUpdate". It goes like this

Private Sub Suburb_AfterUpdate()

PostCode = Suburb.Column(2)

End Sub

Don't forget that the calculations for Access starts like this. First Column is Column 0, second column is column 1 etc.
It would be the best to add an ID field if you wanted for the records to show in coordination.

Good Luck
Abbosy
 

Users who are viewing this thread

Back
Top Bottom