Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Unanswered: Working With Recordset

    I am working with records set tring to get a varialbe = the output of a sql query. This is my code

    Dim Row_count As Integer
    Dim Cur_DB As Database
    Dim Record_Set As Recordset
    Dim Count_of_records As String

    Count_of_records = "select count(*) from Table_PCRKMS_Local_Data"

    Set Cur_DB = CurrentDb()
    Set Record_Set = Cur_DB.OpenRecordset("Table_PCRKMS_Local_Data", "Count_of_records")
    test.Value = Record_Set
    DoCmd.RunSQL "UPDATE [Table:_PCRKMS_User_Defaults]" & _
    " SET Row_Count = " & Record_Set

    I have yet to have any fortune with this, right now im getting a data type conversion error. Can anyone see whats wrong here?
    Jim

  2. #2
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Is there a convert function in vba?
    I think the problem is with my select being numeric and trying to insert it into a string variable.
    Jim

  3. #3
    Join Date
    Nov 2002
    Location
    The Netherlands
    Posts
    61
    YourString=Cstr(yourInt)

    This will change integers(Or other Variables) to strings.

  4. #4
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Dim Row_count As Integer
    Dim Cur_DB As Database
    Dim Record_Set As Recordset
    Dim Count_of_records As String
    Dim Quote As String

    Quote = Chr$(34)

    Count_of_records = "select count(*) from Table_PCRKMS_Local_Data"

    Set Cur_DB = CurrentDb()
    Set Record_Set = CStr(Cur_DB.OpenRecordset("Table_PCRKMS_Local_Data ", "Count_of_records"))
    test.Value = Record_Set

    puting the cstr( ) gave me the error type mismatch.
    any ideas?

Posting Permissions

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