Hello Everyone
I tried the above example exactly as stated here and it did work, however, I then
tried to apply to my real database and that was when the wheels fell off. After much
examining and experimenting I discovered the main difference between my database and
this one was that in my equivalent to the Products table the Category was a look up column
in the table whereby one looked up and inserted the category from a drop down list which
got it's data from the Category table. For some reason the sub list wouldn't work so I made the
assumption that instead of text I am getting a number which represent it's position in an array.
My two table are Country & Track so I want to first select a country and then the tracks in that
country.
Hope I am making sense so far I am a new Access programmer
So on my form I created an unbound textbox which read the array number of the first
combo box using this in the Control Source property
=DLookUp("[Country]","Country","[CountryID]=" & [Forms]![Form2]![Country])
On the form (Form2) I have a combo box as in the example above but with the following
satement in the Row Source property
SELECT [Country].[CountryID], [Country].[CountryName], [Country].[CountryCode] FROM Country ORDER BY [CountryName];
So when I select a country it's position in the array is reflected in the text box
Then I used the OnChange rather than the AfterUpdate event procedure and placed the follwing
VB code in that:
Private Sub Country_Change()
Me.cboTrack.RowSource = "SELECT TrackName FROM Track WHERE Country = " & Me.txtCountry.Value & " ORDER BY TrackName"
Me.cboTrack = Me.cboTrack.ItemData(0)
End Sub
This works well and reliably, but as I say I am new to Access 2007 and maybe there is an easier way,
If anyone knows of one I'd be happy to see it.
Also make sure that when the security warning appears below the ribbon strip that you click on
it and select "Allow Content". If you don't the VBA code won't work, but your SQL will which is very
confusing when you're new to this and your program seems to only half work