thegentleman
IS-IT--Management
I'm trying to create a simple recordset function. Here is the code:
Function CreateCityString(GroupId As String)
Dim TheDB As Database
Dim RS As Recordset
Dim strSQL As String
Dim CityString As String
Dim City As String
Set TheDB = CurrentDb
strSQL = "SELECT Airport_Code FROM dbo_Airport_Gping WHERE Loc_Gp_Code = '" & GroupId & "';"
Set RS = TheDB.OpenRecordset(strSQL)
While Not RS.EOF
City = RS(Airport_Code)
CityString = CityString & ", " & City
RS.MoveNext
Wend
CreateCityString = CityString
End Function
Whenever I run this however I get the following error:
User-defined type not defined
And Access Higlights the following line:
Dim TheDB As Database
Please help me!!!
tg
Function CreateCityString(GroupId As String)
Dim TheDB As Database
Dim RS As Recordset
Dim strSQL As String
Dim CityString As String
Dim City As String
Set TheDB = CurrentDb
strSQL = "SELECT Airport_Code FROM dbo_Airport_Gping WHERE Loc_Gp_Code = '" & GroupId & "';"
Set RS = TheDB.OpenRecordset(strSQL)
While Not RS.EOF
City = RS(Airport_Code)
CityString = CityString & ", " & City
RS.MoveNext
Wend
CreateCityString = CityString
End Function
Whenever I run this however I get the following error:
User-defined type not defined
And Access Higlights the following line:
Dim TheDB As Database
Please help me!!!
tg