Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Suffolk, England
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Query at runtime (Access2000)

    I must be doing something really stupid - but I can't see it!
    When I run the following code, I get 'DataType Conversion error' - what am I doing wrong?
    Dim qry As QueryDef
    Dim strSQL As String
    Dim db As Database
    strSQL = "SELECT CostCentreReportStructure.CostCentre, CostCentreReportStructure.Name,_ CostCentreReportStructure.Report2 FROM CostCentreReportStructure WHERE (((CostCentreReportStructure.Report2)_ Like " ' Fred Bloggs' "));"
    Set qry = db.CreateQueryDef("")
    qry.SQL = strSQL
    Set rec = qry.OpenRecordset("")

    It throws up the error on the last command
    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Query at runtime (Access2000)

    The syntax for opening a recordset on the querydef is: Set rec = qdf.OpenRecordset

    Since you've already created the querydef, the only arguments you might need would be something like dbOpenDynaset and possibly a locking type. YOu don't need a source argument because the querydef object supplies the source.
    Charlotte

Posting Permissions

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