Re: Type Mismatch

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi John,

If you have a reference to the ADODB library as well as to DAO,
Dim RD As Recordset
will refer to ADODB.Recordset or DAO.Recordset depending which is first
in the list, but
Set RD = db.OpenRecordset(SqlStmt, dbOpenDynaset, dbSeeChanges)
returns a DAO.Recordset.

Either get rid of the ADODB reference, or disambiguate the declaration:
Dim RD As DAO.Recordset
(or both).

On Wed, 1 Jun 2005 13:31:01 -0700, "John"
<John@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>For some reason I am getting a type mistch error message when I try to open
>the recordset. I even went to the immediate window to get the SQL statement
>I am supplying and put it into a query and it worked fine. I am not sure
>when it is not working. Any suggestions would be greatly appreciated.
>
>Thanks in advance,
>
>CODE:
> Dim SQL2 As String
> Dim SQL3 As String
> Dim sql4 As String
> Dim sql5 As String
> Dim sql6 As String
> Dim sql7 As String
> Dim SqlStmt As String
> Dim CurrBidNum As Double
> Dim db As Database
> Dim RD As Recordset
> Dim SQL As String
>
> Set db = CurrentDb()
>
> CurrBidNum = [Forms]![Main]![SpecDefaults]![BidNum]
>
> SQL2 = "SELECT BidNum FROM BidInfo "
> SQL3 = "WHERE GCJob = '" & GCJob & "' "
> sql4 = "AND Phase = '" & Phase & "' "
> sql5 = "AND SpecGroup = '" & SpecGroup & "' "
> sql6 = "ORDER BY BidNum DESC"
> SqlStmt = SQL2 & SQL3 & sql4 & sql5 & sql6
>
> Set RD = db.OpenRecordset(SqlStmt, dbOpenDynaset, dbSeeChanges)
>
> If RD.Fields(0).Value = CurrBidNum Then
> MsgBox ("Success")
> Else
> MsgBox ("Fail")
> End If

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
.



Relevant Pages

  • Re: My VB6 MS Word VBA code crashes Word - Word97
    ... The reason you can't go backwards (that is, compile with a reference to Word ... Dim oWord As Word.Application ' Note early bound is OK here! ... Set oDocuments = oApplication.Documents ' Note this is an early bound ... >>> Dim Firstname As String ...
    (microsoft.public.word.vba.general)
  • Search pattern
    ... Dim strfile As String ... Dim bAddressFound As Boolean ... Dim strCurrentChar As String ...
    (comp.databases.ms-access)
  • Re: Sub reagiert trotz Exit Sub
    ... Dim EVMsg As String ... MsgBox gsMessages ... Ereignisse eintreffen und nachdem die MsgBox vom Benutzer ...
    (microsoft.public.de.vb)
  • Auto Write Name and Merge across
    ... Dim Sheetname01 As String ... Dim WeekName01 As String ...
    (microsoft.public.excel.misc)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)