Results 1 to 27 of 27

Thread: Woka your the best ** Resolved **ADO recordset BOF/EOF

  1. #1

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721

    Woka your the best ** Resolved **ADO recordset BOF/EOF

    Hi

    I have a routine which validates and prints a user input but if
    they go back lets say they entered the wrong info I receive and
    error when I try to refresh the results.

    lets say example
    user inputs id - 125336
    and a shift as 5

    the results printed are like so
    5 125336
    Harris

    but lets say they entered the wrong shift so they press the back button and reenter the shift this is were I am reciving the error
    my code will not let me repaint new input...

    VB Code:
    1. Sub cmdbutshft_click(index As Integer)
    2.    'Remember that the first CommandButton in the array is
    3. 'ALWAYS 0. commandbutton array to determine the packers shift
    4.     Dim intCmd As Integer
    5.        If index = 0 Then
    6.           Strshiftletter = Trim$("1")
    7.         ElseIf index = 1 Then
    8.          Strshiftletter = Trim$("5")
    9.         ElseIf index = 2 Then
    10.          Strshiftletter = Trim$("3")
    11.         ElseIf index = 3 Then
    12.          Strshiftletter = Trim$("4")
    13.     End If
    14.      
    15.      Select Case m_Intwndprogress
    16.        
    17.         Case Is = 10
    18.                 txtinformation.Text = Strshiftletter
    19.                 progressbar_login
    20.          
    21.             If Not ObjRSuser.EOF Then
    22.                 PicResultsOperator.Print "Packers_ID"; vbCrLf; Strshiftletter; ObjRSuser.GetString(, , vbCrLf)
    23.                 txtinformation.SetFocus
    24.                 txtinformation.maxlength = 11
    25.                 txtinformation = ""
    26.             End If
    27.             If ObjRSuser.BOF = False Or True Then
    28.             PicResultsOperator.Print "Packers_ID"; vbCrLf; Strshiftletter; ObjRSuser.GetString(, , vbCrLf)
    29.                   txtinformation.SetFocus
    30.                 txtinformation.maxlength = 11
    31.                 txtinformation = ""
    32.         End If
    33.            
    34.    End Select
    35.    For intCmd = 0 To 3 ' Disable caption for each cmd button
    36.             cmdbutshft(intCmd).Caption = ""
    37.              Strshiftletter = vbNullString
    38.    Next intCmd
    39.       Lbltext.Caption = Trim$("Please Enter/code")
    40.        validate_product_code
    41.  End Sub

    Thanks
    Last edited by holly; May 14th, 2003 at 01:44 AM.
    ** HOLLY **

  2. #2
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Errr...not quite sure what ya codes doing, but I can tell you that:
    VB Code:
    1. If ObjRSuser.BOF = False Or True Then
    Is definately a bit strange...that is statement will ALWAYS be true!
    I think you may want to change this line to:
    VB Code:
    1. If NOT objRSUser.BOF And Not objRSUser.EOF Then
    Hope that helps,

    Woka

  3. #3

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    Woka - thanks for your suggestions but unfortunatly I'm still
    receiving the same error....either eof or bof is true......

    Have you anymore suggestions!!!
    ** HOLLY **

  4. #4
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Ok, how about:
    VB Code:
    1. If NOT (objRSUser.BOF Or objRSUser.EOF) Then
    If either of them is TRUE then the IF statement will be FALSE and will not fire the code off to print the details to your form...Actually, the line of code I posted prior to this post does exactally the same...

    What line of code are you getting the error on???

    Woka

  5. #5

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    The line of code I geeting the error on is
    VB Code:
    1. If Not ObjRSuser.BOF And Not ObjRSuser.EOF Then
    2.                 PicResultsOperator.Print "Packers_ID"; vbCrLf; Strshiftletter; ObjRSuser
    3.                 txtinformation.SetFocus
    4.                 txtinformation.maxlength = 11
    5.                 txtinformation = ""
    6.         End If

    The second if statement this is when I try to repaint the new objrsuser and shift values.

    Thanks
    ** HOLLY **

  6. #6

  7. #7

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    it appears so!!!!
    ** HOLLY **

  8. #8

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    Woka

    It appears to be
    VB Code:
    1. ObjRSuser.GetString(, , vbCrLf)
    2. of the second if statement

    the error occurs when I try to print out the objrsuser results
    for a second time...

    Have you any ideas


    thanks
    ** HOLLY **

  9. #9
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478
    Have you placed wolka's suggestion instead of the second if statement ?
    Code:
    If Question = Incomplete Then
       AnswerNextOne
    Else
       ReplyIfKnown
    End If
    cu Swatty

  10. #10

  11. #11

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    This is my code
    VB Code:
    1. Sub cmdbutshft_click(index As Integer)
    2.    'Remember that the first CommandButton in the array is
    3. 'ALWAYS 0. commandbutton array to determine the packers shift
    4.     Dim intCmd As Integer
    5.        If index = 0 Then
    6.           Strshiftletter = Trim$("1")
    7.         ElseIf index = 1 Then
    8.          Strshiftletter = Trim$("5")
    9.         ElseIf index = 2 Then
    10.          Strshiftletter = Trim$("3")
    11.         ElseIf index = 3 Then
    12.          Strshiftletter = Trim$("4")
    13.     End If
    14.      
    15.      Select Case m_Intwndprogress
    16.        
    17.         Case Is = 10
    18.                 txtinformation.Text = Strshiftletter
    19.                 progressbar_login
    20.          
    21.           If Not ObjRSuser.EOF Then
    22.                 PicResultsOperator.Print "Packers_ID"; vbCrLf; Strshiftletter; ObjRSuser.GetString(, , vbCrLf)
    23.                 txtinformation.SetFocus
    24.                 txtinformation.maxlength = 11
    25.                 txtinformation = ""
    26.          End If
    27.         If (ObjRSuser.BOF = True Or ObjRSuser.EOF = True) Then
    28.              [quote][b]   PicResultsOperator.Print "Packers_ID"; vbCrLf; Strshiftletter; ObjRSuser.GetString(, , vbCrLf) [/b][/quote][b][/b]
    29.                 txtinformation.SetFocus
    30.                 txtinformation.maxlength = 11
    31.                 txtinformation = ""
    32.          End If
    33.    
    34.    End Select
    35.    For intCmd = 0 To 3 ' Disable caption for each cmd button
    36.             cmdbutshft(intCmd).Caption = ""
    37.              Strshiftletter = vbNullString
    38.    Next intCmd
    39.       Lbltext.Caption = Trim$("Please Enter code")
    40.        validate_product_code
    41.  End Sub

    now the line which is giving me the error is
    VB Code:
    1. PicResultsOperator.Print "Packers_ID"; vbCrLf; Strshiftletter; ObjRSuser.GetString(, , vbCrLf)

    The error is
    2031 - either eof or bof is true, current record has been deleted -
    well it is something on these lines......

    now what I was thinking is the objrsuser has already got the
    values I need printing, so I thought the error must be occuring
    within the second
    if statement
    VB Code:
    1. ObjRSuser.GetString(, , vbCrLf)

    Thanks
    The second IF statement allow me to reprint the new values...after
    changing the shift values...
    ** HOLLY **

  12. #12
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Errrrr....?!
    You have:
    VB Code:
    1. If (ObjRSuser.BOF = True Or ObjRSuser.EOF = True) Then
    So of course it's going to give you an error because the recordset is either at the beginning of the file, or at the end of the file...

    Like I posted twice before you need either:
    VB Code:
    1. If NOT objRSUser.BOF And Not objRSUser.EOF Then
    OR
    VB Code:
    1. If NOT (objRSUser.BOF Or objRSUser.EOF) Then
    Not having a go or anything, but I can't really help you if you type random code into your app instead of the code I suggest...I was well confused because the code I posted should handle this error, but you said you still got it But you haven't used my code...

    Replace you IF statement with either of the 2 I posted. They are exactally the same, just written differently...

    Woka

  13. #13

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    Woka

    I think we are getting our wires crossed....I have tried your code
    If NOT objRSUser.BOF And Not objRSUser.EOF Then
    and It does not work .......this is why, when I post my code
    you're suggestions are not visible.....


    ok, the error has been taken care of but I need to execute the
    code within the IF STATEMENT inorder to print out the new
    shift values....

    Thanks for youre help
    ** HOLLY **

  14. #14
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    You can't....
    If either the recordsets EOF or BOF is TRUE, then it's not pointing at a current record, thus you will get an error...Do you have .MoveNext or .MovePrevious at all in your code?

    How do you scroll through the code...?


    My code did work, it stopped the error, but it didn't display and text, this is down to another problem further up the line...

    Can you post the entire form on here please, and I'll take a little look for you.

    Woof

  15. #15

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    Woka

    Youre very kind....I have attached the form and remove confidential info...

    Thanks for taking the time to check out my code...Please feel free
    to comment!!!!!

    Last edited by holly; May 13th, 2003 at 08:10 AM.
    ** HOLLY **

  16. #16
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Right...where to start...Hmmmmmmm...

    1stly, get rid of that END statement....
    Bad, bad, bad command
    Your UnLoad event destroys all your objects and other forms, so there is no need for the END command...

    Also...change all you buttons for the numbers to an control array:
    VB Code:
    1. Private Sub cmdNumber_Click(Index As Integer)
    2.     With txtInformation
    3.         .Text = Trim$(.Text) & CStr(Index)
    4.         .SelStart = Len(.Text)
    5.         .SetFocus
    6.     End With
    7. End Sub
    Does that make sense?

    change your .Open statement to:
    VB Code:
    1. .Open strsql, m_objoCn,adOpenForwardOnly,adLockReadOnly
    This is makes the code faster...and does not lock the database...

    I can't see how that Sub is fired off if you click the back button

    I think it might be because when you click the back button is resets the txtInformation to vbNullstring ("")

    Woka

  17. #17

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    Woka - I know youre probably fed up of me by now but
    Thanks - I have made the changes you've recommended....Just as
    a matter of interests....what do you think of the overall code...
    but, bear in mind, I'm new to VB.....

    Going back to the original problem...if I place this in my second
    if statement then the code executes...(is this bad programming)
    VB Code:
    1. If ObjRSuser.BOF = False And ObjRSuser.EOF = True Then
    2.                PicResultsOperator.Print "Packers_ID"; vbCrLf; Strshiftletter
    3.                 txtinformation.SetFocus
    4.                 txtinformation.maxlength = 11
    5.                 txtinformation = ""
    6.          End If
    It will reprint the shift letter but I also need the objrsuser object..
    to print....why does it seem as though the objrsuser values are
    lost

    Once again thanks for all your help!!
    ** HOLLY **

  18. #18

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    Please Help!!!!!!!

    Going back to the original problem...if I place this in my second
    if statement then the code executes...(is this bad programming)

    visual basic code:--------------------------------------------------------------------------------If ObjRSuser.BOF = False And ObjRSuser.EOF = True Then
    PicResultsOperator.Print "Packers_ID"; vbCrLf; StrshiftletterObjRSuser.GetString(, , vbCrLf)
    txtinformation.SetFocus
    txtinformation.maxlength = 11
    txtinformation = ""
    End If
    --------------------------------------------------------------------------------

    It will reprint the shift letter but I also need the objrsuser object..
    to print....why will the objrsuser values not print!!!

    Thanks
    ** HOLLY **

  19. #19

  20. #20

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    Woka

    the number returned is -1

    why???
    ** HOLLY **

  21. #21
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Because I want to see what the record count is for that recordset. I have no idea if you have records in there...it could be empty for all I know

    Try changing you .OPEN statement back to what you had it as then run again and tell me what the recordcount is...

    Woka

  22. #22
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627
    Open using adopenkeyset, that should give a record count.

  23. #23

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    The value has changed to 1
    ** HOLLY **

  24. #24
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    OK, that's good...
    Change your IF statement code to
    VB Code:
    1. If ObjRSuser.RecordCount = 1  Then
    2.                 objRSUser.MoveFirst
    3.                 PicResultsOperator.Print "Packers_ID"; vbCrLf; Strshiftletter; ObjRSuser.GetString(, , vbCrLf)
    4.                 txtinformation.SetFocus
    5.                 txtinformation.maxlength = 11
    6.                 txtinformation = ""
    7.          End If
    That should do the trick...

    Woka

  25. #25

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    Woka

    I will have to test your solution in the morning - I will let you know
    how I get on (fingers are crossed) in the meantime I would
    like to thankyou for youe patience and especially your help!

    Thanks again

    PS See ya tomorrow - I know what youre think....not if I see you
    first (ha, ha)
    ** HOLLY **

  26. #26

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    Woka - what can one say except a big thankyou... Maybe my
    code is alot to desire but you managed to fix and thanks a
    million for having the patience.......

    Thanks again for all your help!!!!
    ** HOLLY **

  27. #27

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