Results 1 to 5 of 5

Thread: where is the error???

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Earth, I think!!
    Posts
    249

    where is the error???

    I've got made a macro command with this code :

    Sub AdoRefresh()

    Dim rs As New ADODB.Recordset
    Dim userentry As String
    Dim strdtfrom As String
    Dim strdtto As String
    Dim sql1 As String
    Dim intCount As Integer

    intCount = 1
    strdtfrom = "01/07/2003"
    strdtto = "07/07/2003"
    userentry = "247"
    Worksheets("test").Range("A2:C2000").ClearContents

    Dim Connect As String

    sql1 = "SELECT DOCUMENTS.f_docnumber, DOCUMENTS.date as DateTime FROM DOCUMENTS WHERE date >= TO_DATE ('" + strdtfrom + "', 'DD/MM/RRRR') AND date < TO_DATE ('" + strdtto + "', 'DD/MM/RRRR') AND user = " + userentry + " ORDER BY date"
    Connect = "Provider=MSDAORA;Password=pass;User ID=userid;Data Source=mydb"
    rs.Open sql1, Connect

    ' Set header values for sheet 1.
    With Worksheets("test").Rows(1)
    .Font.Bold = True
    .Cells(2, 1).Value = "RowNum"
    .Cells(2, 2).Value = "Doc"
    .Cells(2, 3).Value = "Date & Time"
    .Cells(2, 4).Value = "Total Time"
    End With
    With rs
    Do While Not .EOF
    Sheets("test").Cells(intCount + 2, 2) = !f_docnumber
    intCount = intCount + 1
    .MoveNext
    Loop
    End With
    End Sub

    i got error(1004) on this line:

    Sheets("test").Cells(intCount + 2, 2) = !f_docnumber

    but i can't underestand why seems everything o.k.
    any suggestions ?????
    Last edited by alazarou; Aug 6th, 2003 at 01:51 PM.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    I'm going to guess that "f_docnumber" is a field in the recordset, right?
    if so !f_docnumber won't work....
    BUT, rs!f_docnumber will....
    The ! notation with recordset doesn't work within the With rs structure.... the With is only a shortcut to the object model, it has no effect on the recordset itself.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Earth, I think!!
    Posts
    249
    no doesn't work with rs!f_docnumber
    the same error in the same line

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Earth, I think!!
    Posts
    249
    I tryed this:
    I changed the field name f_docnumber(number)
    with an other from the same table f_docname(varchar) and the code works.
    so, is there anyone who knows why doesn't work with numbers???

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Earth, I think!!
    Posts
    249
    i get it!!!!!!
    Cstr(rs!f_docnumber)

Posting Permissions

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



Click Here to Expand Forum to Full Width