Advertisement

06.16.2008 at 08:50PM PDT, ID: 23490314
[x]
Attachment Details

How to deal with type mistach error?

Asked by angie_angie in Access Coding/Macros

Tags: MS Access, VBA, Type Mismatch

I have the following code. Can anyone tell me why it doesn't work? I have a table called myTable and there is one field called aField and only one value (of number type) under this field, which is 234.

Sub test()
myArrayAsAString = "123,456,789"
strSql = "Select * From myTable Where [aField] Not In ('"
For x = 0 To UBound(Split(myArrayAsAString, ","))
    strSql = strSql & Split(myArrayAsAString, ",")(x) & "', '"
Next
strSql = Left(strSql, Len(strSql) - 3) & ")"
Debug.Print (strSql)
With CurrentDb.OpenRecordset(strSql)
    Debug.Print .Fields(aField)
    .Close
End With
End Sub
Start Free Trial
 
 
[+][-]06.16.2008 at 09:07PM PDT, ID: 21799501

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Access Coding/Macros
Tags: MS Access, VBA, Type Mismatch
Sign Up Now!
Solution Provided By: pratima_mcs
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.17.2008 at 01:10AM PDT, ID: 21800745

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.17.2008 at 01:32AM PDT, ID: 21800849

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628