Re: Query in VBA Type Mismatch
- From: "Duane Hookom" <duanehookom@xxxxxxxxxxxxxxxxx>
- Date: Tue, 7 Feb 2006 16:54:03 -0600
Try paste the SQL into a new, blank query. Check to see if Access places ""
around the 1.
--
Duane Hookom
MS Access MVP
--
"James Stephens" <JamesStephens@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B26F04B1-82EA-42DD-9D60-86CF094D5EF3@xxxxxxxxxxxxxxxx
Here is what I get in the debug statement:
SELECT [tblEmployee_Airport].[Airport_Code] From [tblEmployee_Airport]
WHERE
([tblEmployee_Airport].[Employee_Code] = 1);
The value what the query is looking up from the table is a Number set to
Long Interger
The exact error I get is Run Time Error 13, Type Mismatch
My guess is that it has something to do with the criteria, but I can't
seem
to make it work.
Thanks,
Jim
"Duane Hookom" wrote:
I am having trouble seeing which line of code raises the error....
What do you get in the strSQL debug?
Try to be explicit with your Dim's
Dim db As DAO.Database
Dim rs As DAO.Recordset
--
Duane Hookom
MS Access MVP
--
"James Stephens" <JamesStephens@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:A0F19BA9-E2D7-460F-9083-62B6D8BF1764@xxxxxxxxxxxxxxxx
I have a query that calls a function to get a list of concatenated
values.
I
have used it before and it works, but I am trying to use it with a
different
query and I get a type mismatch error. Here is the function: (the
value
for
EmployeeCode being passed from the query is Long Interger from an
Autonumber
Field)
Function GetAirports(EmployeeCode As Long) As String
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim strReturn As String
Set db = CurrentDb
strSQL = "SELECT [tblEmployee_Airport].[Airport_Code] From
[tblEmployee_Airport] WHERE ([tblEmployee_Airport].[Employee_Code] = "
&
EmployeeCode & ");"
Debug.Print strSQL
Set rs = db.OpenRecordset(strSQL)
With rs
If Not (.EOF And .BOF) Then
Do Until .EOF
strReturn = strReturn & !Airport_Code & vbCrLf
.MoveNext
Loop
End If
.Close
End With
If Len(strReturn) > 0 Then
strReturn = Left(strReturn, Len(strReturn) - 2)
End If
GetAirports = strReturn
End Function
Anybody got an idea as to what I am doing wrong?
Thanks,
Jim
.
- References:
- Re: Query in VBA Type Mismatch
- From: Duane Hookom
- Re: Query in VBA Type Mismatch
- From: James Stephens
- Re: Query in VBA Type Mismatch
- Prev by Date: Re: Need Help with date calculations!!!
- Next by Date: Re: A subquery? Not sure if this is doable?
- Previous by thread: Re: Query in VBA Type Mismatch
- Next by thread: Re: Query in VBA Type Mismatch
- Index(es):
Relevant Pages
|
Loading