If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Type Mismatch

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-16-03, 06:57
Jumper Jumper is offline
Registered User
 
Join Date: Sep 2003
Location: Gloucester
Posts: 28
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
Reply With Quote
  #2 (permalink)  
Old 09-16-03, 07:11
mashinovodja mashinovodja is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 09-16-03, 08:42
DoktorBlue DoktorBlue is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 09-16-03, 09:22
Jumper Jumper is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On