Results 1 to 13 of 13

Thread: [RESOLVED] Run-time error '3001'

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Resolved [RESOLVED] Run-time error '3001'

    Hi,

    I am receiving Run-time error '3001' Arguments of the wrong type, are out of acceptable range or are in conflict with eachother.

    Code:
       If Not Text1.Text = rs.Fields("PlayerID") Then
                rs.AddNew 'adding new record
             Else
                rs.Find rs.Fields("PlayerID") = Text1.Text
             End If
                Text1.Text = rs.Fields("PlayerID")
                rs.Fields("Score") = ScoreHolder
                rs.Update 'Handle the data
    the error is on this line

    Code:
        rs.Find rs.Fields("PlayerID") = Text1.Text
    Not sure why I am receiving that error? Another project of mine using that code has no problems.

    Code:
                If Not Form1.txtContactID.Text = rs.Fields("CustomerID") Then
                rs.AddNew 'adding new record
                 Else
                 rs.Find Form1.txtContactID.Text = rs.Fields("CustomerID")
                 End If
    Thanks,


    Nightwalker
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: Run-time error '3001'

    Should it not be like this?
    Code:
    rs.Find "PlayerID = '" & Text1.Text & "'"
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Run-time error '3001'

    Or if it is numeric then
    Code:
    rs.Find "PlayerID = " & Text1.Text

  4. #4

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Run-time error '3001'

    In debug mode putting the cursor over both

    Code:
    Text1.Text = rs.Fields("PlayerID")
    Text1.Text and rs.Fields("PlayerID") both have the value of "x" which is the player token for tic tac toe. However, I cannot figure out why

    Code:
    rs.find
    would be skipped over because the values look identical?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Run-time error '3001'

    I rewrote the score sub as so and it works.

    Code:
    Private Sub score()
    If rs.RecordCount < -1 Then
       MsgBox "Please setup the database first!"
    Else
                  rs.Find "PlayerID = '" & Retval & "'"
                    rs.Fields("PlayerID") = Retval
                rs.Fields("Score") = ScoreHolder
                rs.Update 'Handle the data
    End If
    End Sub
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: [RESOLVED] Run-time error '3001'

    Code:
    If rs.RecordCount < -1 Then
    ??
    How could you have a recordcount <-1 ? Recordcount will be either 0 or >0 or possibly -1 if an error occurs

  7. #7

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [RESOLVED] Run-time error '3001'

    Quote Originally Posted by DataMiser View Post
    Code:
    If rs.RecordCount < -1 Then
    ??
    How could you have a recordcount <-1 ? Recordcount will be either 0 or >0 or possibly -1 if an error occurs
    That should have been either 0 or = -1.

    Edit:

    However, when I ran the code it displayed the message only when it could not find the data.
    Last edited by Nightwalker83; Mar 21st, 2014 at 07:08 PM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  8. #8
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: [RESOLVED] Run-time error '3001'

    hmm that does not make sense either since the find would not have been executed yet

  9. #9

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [RESOLVED] Run-time error '3001'

    Quote Originally Posted by DataMiser View Post
    hmm that does not make sense either since the find would not have been executed yet
    Actually, I am correct in my original assumption because I am checking whether or not the default score "0" has been entered in in the database to start the game. "0" would be at position "-1" so anything less than that would mean the table is empty.

    Code:
     If rs.RecordCount < -1 Then MsgBox "Please setup the database first!"
    and I have now placed that conditional statement after connecting to the database instead of at the start of saving the score to the database.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  10. #10
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: [RESOLVED] Run-time error '3001'

    There is no position -1

    Recordcount returns the number of records in the recordset if there is 1 record it returns 1 if there are no records it returns 0. The only time I have ever saw a value of -1 is in cases where the cursor does not support the .recordcount property in which case it returns -1 even if there are 1 million records returned.

  11. #11

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [RESOLVED] Run-time error '3001'

    How you solve the problem? I have tried checking both either BOF or EOF and whether or not the values for the "PlayerID" and "Score" were empty but I keep receiving run time error '3021'.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  12. #12
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,255

    Re: [RESOLVED] Run-time error '3001'

    Quote Originally Posted by Nightwalker83 View Post
    How you solve the problem? I have tried checking both either BOF or EOF and whether or not the values for the "PlayerID" and "Score" were empty but I keep receiving run time error '3021'.
    If you want a reliable working Rs.Recordcount, you will simply have to ensure
    Cnn.Cursorloaction = adUseClient
    on the Connection you use, to open your Rs from.

    That's what DataMiser hinted at with "-1 is returned only when the Cursor(Type) does not support ..." ...
    The Rs cannot hand out a concrete Rs.Recordcount (yet). With a CursorType of adUseServer, the returned
    Rs "knows" only that:
    "there are records, but how many I cannot tell you yet, I'll give you a -1 to signalize that".

    Olaf
    Last edited by Schmidt; Mar 23rd, 2014 at 12:51 AM.

  13. #13

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [RESOLVED] Run-time error '3001'

    rs.Find "PlayerID like '" & Retval & "'"for some reason the find is having issues with the equals sign. I will try "like" and see if that solves the issue.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

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