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 / Modules / DAO / VBA / April 2008

Tip: Looking for answers? Try searching our database.

Type mismatch

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
na9999 - 30 Apr 2008 12:14 GMT
Hi
Sorry if this is obvious but have now spent hours playing around with no joy.
Keep getting a type mismatch error with this code. I have DAO as a reference,
but not ADO. I have tried setting both as reference s and then just using ADO
but then the Dim dbs As Database and Dim qdf As QueryDef don't work.

Any help would be great!

Thanks

Private Sub cmdCreateQuery_Click()
On Error GoTo Err_cmdCreateQuery_Click

Dim strSQL As String
Dim qdf As DAO.QueryDef
Dim frmname As String
Dim dbs As DAO.Database

Set dbs = CurrentDb

strSQL = "SELECT Main.Absolut_Referece, Main.Title, "
strSQL = strSQL & "Main.Standard_Type, Main.Number, Main.Part, "
strSQL = strSQL & "Main.Subsection, Main.Year"
strSQL = strSQL & "Main.Modules"

Select Case Forms![practice]![findtype]
  Case 1
      strSQL = strSQL & " WHERE ((Main.Standard_Type)=[findtype])"
     
  Case Else
      strSQL = strSQL & " WHERE ((Main.Standard_Type)=" * ")"
End Select

strSQL = strSQL & " AND "

Select Case Forms![practice]![findkeyword]
  Case 1
      strSQL = strSQL & " WHERE ((Main.Title) LIKE " * " [findkeyword]" * ")
"
     
  Case Else
      strSQL = strSQL & " WHERE ((Main.Title)=" * ")"
End Select

strSQL = strSQL & " AND "

Select Case Forms![practice]![findnumber]
  Case 1
      strSQL = strSQL & " WHERE ((Main.Number)=[findnumber])"
     
  Case Else
      strSQL = strSQL & " WHERE ((Main.Number)=" * ")"
End Select

strSQL = strSQL & " AND "

Select Case Forms![practice]![findmodule]
  Case 1
      strSQL = strSQL & " WHERE ((Main.Modules) LIKE " * " [findmodule]" *
")"
     
  Case Else
      strSQL = strSQL & " WHERE ((Main.Modules)=" * ")"
End Select

MsgBox strSQL

dbs.QueryDefs.Delete "query"
Set qdf = dbs.CreateQueryDef("query", strSQL)

DoCmd.OpenQuery "query", acNormal, acEdit

     
 

Exit_cmdCreateQuery_Click:
  Exit Sub

Err_cmdCreateQuery_Click:

  If Err.Number = 3265 Then
      Resume Next
  Else
'        MsgBox Err.Number
      MsgBox Err.Description
      Resume Exit_cmdCreateQuery_Click

  End If
 
End Sub
Jeff Boyce - 30 Apr 2008 12:31 GMT
Already responded to in another newsgroup.  It's rarely necessary to post to
more than one group.

Signature

Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

> Hi
> Sorry if this is obvious but have now spent hours playing around with no joy.
[quoted text clipped - 83 lines]
>
> End Sub
 
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.