Results 1 to 4 of 4

Thread: Type Mismatch

  1. #1
    Join Date
    Sep 2003
    Location
    Gloucester
    Posts
    28

    Unanswered: Type Mismatch

    Tugging forelock and grovelling for some assist
    I have an Access Database which tracks relationships between Entities.

    Each entity can have many links and each link can point to different sub link which eventually shows all relationships.

    I first put this together in Access97 and now converting it to Access 2000
    (The Access 97 version runs without any probs)

    In the Access 2000 version when I try to create a new link I get a Type mismatch error in the Set MT=DB.OpenRecordset. Can anyone see any error here?

    Private Sub Button3_Click()
    Dim DB As Database, MT As Recordset, vLinkNr
    Set DB = DBEngine.Workspaces(0).Databases(0)
    Set MT = DB.OpenRecordset("Tlinks", DB_OPEN_DYNASET)
    MT.AddNew
    vLinkNr = MT!Linknr
    MT!EntityANr = Forms!Entities!EntityNr
    MT!EntityBNr = Forms!Links!EntityNr
    MT!Direction = 0
    MT!Strength = "Confirmed"
    MT!Colour = "Black"
    MT.Update
    MT.Close
    DoCmd.Close
    DoCmd.OpenForm "MakeLinks"
    Forms!MakeLinks.RecordSource = "Select Tlinks.*, Entities.Label1, TIcons.Icon, Entities_1.Label1, TIcons_1 FROM (TIcons AS TIcons_1 INNER JOIN Entities AS Entities_1 ON TIcons_1.IconNr = Entities_1.IconNr) INNER JOIN ((Entities INNER JOIN TIcons ON Entites.IconNr = TIcons.IconNr) INNER JOIN Tlinks ON Entities.EntityNr = TLinks.EntityANr) On Entities_1.EntityNr = Tlinks.EntityBNr WHERE (((Tlinks.LinkNr)= " & Str(vLinkNr) & "));"
    End Sub

  2. #2
    Join Date
    Aug 2003
    Location
    Belgrade
    Posts
    68
    By default, Access 97 uses DAO for data Access. But this so not so in Access 2000 and later, where ADO is the preferred method and DAO is an option. So, if you want to continue to use DAO, you must explicitly insert a reference to the DAO library.

    Also, to avoid confusion, in all Dim statements prefix object types with the correct library. For example:

    Dim DB As Database, MT As Recordset, vLinkNr

    should be changed into

    Dim DB As DAO.Database, MT As DAO.Recordset, vLinkNr

    Hope this helps.

  3. #3
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447
    Actually, it's not only confusion, but since ADO is the default, MT will be declared as an ADODB.RecordSet implicitely. You will have to add both the DAO referecne, and to declare MT as DAO.RecordSet.
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

  4. #4
    Join Date
    Sep 2003
    Location
    Gloucester
    Posts
    28
    Thanks guys - I had included the DAO reference but left in an ActiveX reference.

    Once I removed that - got a little further along the trail.

    Still not working fully but many thanks for the speedy assist.

    No doubt you will be seeing more of me and my queries before this is complete - hopefully before I pass on!!!!! lol

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •