Results 1 to 5 of 5

Thread: Strange Error

  1. #1
    Join Date
    Jul 2004
    Posts
    18

    Unanswered: Strange Error

    Hi

    Im encountering a problem which is quite new to me. I have not written code for over a year now and would like some assistance with this problem if possible.

    I have the following loop code

    Option Explicit

    Option Compare Database


    Private Function Department_Data()

    Dim dbs As Database
    Dim rsdept As Recordset
    Dim qdf As Querydef


    Set dbs = CurrentDb
    Set rsdept = dbs.OpenRecordset("divisionanddepartments") ---- this line
    Set qdf = dbs.QueryDefs("Perido sku update")

    Do Until rsdept.EOF
    qdf("enterdept") = rsdept!["Department Number"]
    qdf.Execute

    Loop

    rsdept.Close



    End Function


    HOwever when trying to step through the data I am getting an error on the highlighted line which says run time error 13 type mismatch. I do not understand why yhis is happening??

    ANy ideas??

    Thanks in advance

    SAYED

  2. #2
    Join Date
    Feb 2004
    Location
    CT,USA
    Posts
    250
    If "divisionanddepartments" is a table or query name, try without the "". When you use "" what's between them must be an SQL statement.

  3. #3
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    What version of Access are you using? If you are using something other than Access 97 then you will probably need to add a reference to DAO and add DAO. to the beginning of the Dim statements.

    Dim dbs As DAO.Database
    Dim rsdept As DAO.Recordset

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Try

    Set rsdept = CurrentDB.OpenRecordset("divisionanddepartments") ---- this line

  5. #5
    Join Date
    Jul 2004
    Posts
    18
    Hi Guys

    Thank you all for your replies. When I placed the DAO in front of the problem it seemed to work fine.

    Many thanks again

    Sayed

Posting Permissions

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