bind to a mdb database
I am working on a project that requires me to bind to a Microsoft Access Database table. I have to rewrite the LoadData subroutine to bind to the hubs.mdb database. This is what is currently in the code...
Public Sub LoadData()
' The following code was moved from the Me.Load Event Handler
' for use in unit testing
'
'Load small sample of airport hubs into Hubs array
Hubs(0).ID = "ATL"
Hubs(0).City = "Atlanta"
Hubs(0).Lat = "33° 38' 22"" N"
Hubs(0).Lon = "84° 25' 41"" W"
Hubs(1).ID = "BOS"
Hubs(1).City = "Boston"
Hubs(1).Lat = "42° 21' 42"" N"
Hubs(1).Lon = "71° 0' 42"" W"
Hubs(2).ID = "CLE"
Hubs(2).City = "Cleveland"
Hubs(2).Lat = "41° 24' 27"" N"
Hubs(2).Lon = "81° 51' 4"" W"
Hubs(3).ID = "SEA"
Hubs(3).City = "Seattle"
Hubs(3).Lat = "47° 26' 56"" N"
Hubs(3).Lon = "122° 18' 33"" W"
'Load ID1ComboBox List
For Each Airport In Hubs
ID1ComboBox.Items.Add(Airport.ID)
Next
'Load ID2ComboBox List
For Each Airport In Hubs
ID2ComboBox.Items.Add(Airport.ID)
Next
'Set default values for Combo boxes
ID1ComboBox.SelectedIndex = 0
ID2ComboBox.SelectedIndex = 1
End Sub
And this is the table in the database.
Index ID City Lat Lon
0 ATL Atlanta "33° 38' 22"" N" "84° 25' 41"" W"
1 BOS Boston "42° 21' 42"" N" "71° 0' 42"" W"
2 CLE Cleveland "41° 24' 27"" N" "81° 51' 4"" W"
3 DCA Washington D.C. "38° 50' 57"" N" "77° 2' 29"" W"
4 DEN Denver "39° 51' 12"" N" "104° 40' 32"" W"
5 DFW Dallas/Fort Worth "32° 53' 53"" N" "97° 2' 27"" W"
6 DTW Detroit "42° 12' 30"" N" "83° 21' 24"" W"
7 HOU Houston "29° 38' 44"" N" "95° 16' 44"" W"
8 JFK New York "40° 38' 39"" N" "73° 46' 56"" W"
9 LAS Las Vegas "36° 4' 48"" N" "115° 9' 12"" W"
10 LAX Los Angeles "34° 3' 59"" N" "118° 7' 28"" W"
11 MIA Miami "25° 47' 39"" N" "80° 17' 8"" W"
12 ORD Chicago "41° 58' 41"" N" "87° 54' 22"" W"
13 SEA Seattle "47° 26' 56"" N" "122° 18' 34"" W"
14 SFO San Francisco "37° 37' 5"" N" "122° 22' 43"" W"
15 STL St. Louis "38° 44' 50"" N" "90° 21' 41"" W"
And finally I have to Modify the hubs array to hold 16 items. Rewrite the LoadData subroutine to fill the hubs array with data from the hubs.mdb dataset.
Any help with this would be greatly appreciated.
|