Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / October 2005

Tip: Looking for answers? Try searching our database.

Type Mismatch

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
elyse - 26 Oct 2005 04:47 GMT
Hello,

When I try to run the following code:

Dim rec1 As Recordset
  Dim dbs1 As Database
 
  Set dbs1 = CurrentDb
  Set rec1 = dbs1.OpenRecordset("GTGrantApplInfo")
 

With rec1
.AddNew
!Grant_Number = Me![Grant_Number]
!Appl_Recvd_Date = Me![Appl_Recvd_Date]
!Grantee_Number = Me![Grantee_Number]
!GS_Empl_Num = Me![GS_Empl_Num]
!PS_Empl_Num = Me![PS_Empl_Num]
!Notes = Me![Notes]
!Gabi_Disk_Recvd = Me![Gabi_Disk_Recvd]
!Act_Type_Num = Me![Act_Type_Num]
!Prog_Off_Num = Me![Prog_Off_Num]
!Program_Type_Code = Me![Program_Type_Code]
!Period_Year = Me![Period_Year]
!Funding_Per_Begin = Me![Funding_Per_Begin]
!Funding_Per_End = Me![Funding_Per_End]
.Update
End With

I keep getting a Type Mismatch error at line (   Set rec1 =
dbs1.OpenRecordset("GTGrantApplInfo")  

The table name used to be GT_Grant_Appl_Info, so I removed the (underscores)
and created one word.  I then tried to remove the " , but the table wasn't
recognized by the code.  I'm not sure what else to do.  Please help

Thanks in advance
Signature

Elyse

John Vinson - 26 Oct 2005 06:05 GMT
>I keep getting a Type Mismatch error at line (   Set rec1 =
>dbs1.OpenRecordset("GTGrantApplInfo")  

Check Tools... References. Is there a checkmark by Microsoft DAO x.xx
Object Library? How about Microsoft ActiveX Data Objects?

I'd suggest explicitly specifying the DAO object library (which is the
datataype returned by the OpenRecordset method):

Dim dbs1 AS DAO.Recordset

                 John W. Vinson[MVP]    
Douglas J Steele - 26 Oct 2005 11:53 GMT
Actually, the fact that it's not complaining about Dim dbs1 As Database
should indicate that the DAO reference is present.

Disambiguating as Dim rec1 As DAO.Recordset is definitely in order: the
Recordset object exists in both the ADO and DAO models, and since the
reference to ADO is going to be higher in the list than the reference to
DAO, the ambiguous Dim rec1 As Recordset will result in an ADO recordset.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> >I keep getting a Type Mismatch error at line (   Set rec1 =
> >dbs1.OpenRecordset("GTGrantApplInfo")
[quoted text clipped - 8 lines]
>
>                   John W. Vinson[MVP]
elyse - 26 Oct 2005 17:06 GMT
Thanks Douglas,

This worked great.

One other question, If I declare all of my variables using "Early Binding"
(dim rst as ado.recordset), does this mean that I don't have to manua
llyselect References from the Tools menu?  

If true, how do I find out which references goes with which type of variable
(ie: recordset, database, wordobject, date, etc...)?

Thanks again

And thanks to all who repsonded to this thread.
Signature

Elyse

> Actually, the fact that it's not complaining about Dim dbs1 As Database
> should indicate that the DAO reference is present.
[quoted text clipped - 16 lines]
> >
> >                   John W. Vinson[MVP]
Douglas J Steele - 26 Oct 2005 19:31 GMT
No, if you're using Early Binding, then you MUST have a reference. It's Late
Binding that doesn't require a reference to be set.

In answer to your second question, though, you can use the Object Browser.
Hit F2 when you're in the VB Editor.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Thanks Douglas,
>
[quoted text clipped - 31 lines]
> > >
> > >                   John W. Vinson[MVP]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.