Results 1 to 6 of 6

Thread: [Solved] Run-time Error regarding BOF or EOF

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    103

    Resolved [Solved] Run-time Error regarding BOF or EOF

    When I open the "New Customer Maintenance" form (where I could fill out the fields so that they get updated on the datagrid) I get this errror:

    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

    Here's the code:

    VB Code:
    1. Private Sub LoadData()
    2.    
    3.     Dim psql As String
    4.     Set cnn = New ADODB.Connection
    5.    
    6.     cnn.Mode = adModeReadWrite
    7.    
    8.     cnn.Open ("INVENTORY")
    9.  
    10.    
    11.     Set rec = New ADODB.Recordset
    12.    
    13.     rec.CursorType = adOpenKeyset
    14.     rec.LockType = adLockOptimistic
    15.    
    16.    
    17.    
    18.     psql = "select * from tblCustomerInformation "
    19.     psql = psql + " where CustNo = " + Trim(Str(Id))
    20.    
    21.    
    22.     rec.Open psql, cnn, , , 1
    23.  
    24.     *Text2.Text = IIf(IsNull(rec!Fname), "", rec!Fname)
    25.     Text1.Text = IIf(IsNull(rec!Lname), "", rec!Lname)
    26.     Text5.Text = IIf(IsNull(rec!ContactNo), "", rec!ContactNo)
    27.     Text8.Text = IIf(IsNull(rec!EmailAdd), "", rec!EmailAdd)
    28.     Text14.Text = IIf(IsNull(rec!Birthday), "", rec!Birthday)
    29.     'Text9.Text = IIf(IsNull(rec!Gender), "", rec!Gender)
    30.     Text9.Text = IIf(IsNull(rec!Address), "", rec!Address)
    31.     Text13.Text = IIf(IsNull(rec!Comment), "", rec!Comment)
    32.    
    33.  
    34. End Sub

    The line with the asterisk is highlighted when debugged.
    Last edited by sirkeled; Sep 3rd, 2006 at 04:28 AM.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Run-time Error regarding BOF or EOF

    VB Code:
    1. rec.Open psql, cnn, , , 1
    2.  
    3.   [color=red]If [color=red]Not[/COLOR] rec.[color=red]EOF[/COLOR] Then[/COLOR]
    4.     *Text2.Text = IIf(IsNull(rec!Fname), "", rec!Fname)
    5.     Text1.Text = IIf(IsNull(rec!Lname), "", rec!Lname)
    6.     Text5.Text = IIf(IsNull(rec!ContactNo), "", rec!ContactNo)
    7.     Text8.Text = IIf(IsNull(rec!EmailAdd), "", rec!EmailAdd)
    8.     Text14.Text = IIf(IsNull(rec!Birthday), "", rec!Birthday)
    9.     'Text9.Text = IIf(IsNull(rec!Gender), "", rec!Gender)
    10.     Text9.Text = IIf(IsNull(rec!Address), "", rec!Address)
    11.     Text13.Text = IIf(IsNull(rec!Comment), "", rec!Comment)
    12.   [COLOR=Red]End If[/COLOR]
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    103

    Re: Run-time Error regarding BOF or EOF

    It worked. I mean I no longer get the error. But what's the real problem with it? I mean am I missing a record or is there a mismatch on the record name?

    Thanks a bunch.

  4. #4
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Philippines
    Posts
    468

    Re: Run-time Error regarding BOF or EOF

    the problem is there is no records to be return by the sql statement
    try searching a record that does not exist you will have the same error message
    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
    use a142 suggestion
    if you have a problem face it
    but what if your face is your problem
    how can you face it

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Run-time Error regarding BOF or EOF

    on a sidenote, you can also just do:
    VB Code:
    1. Text2.Text = rec!Fname & ""
    2. Text1.Text = rec!Lname & ""
    3. 'etc.
    instead of all those IsNull checks

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    103

    Re: Run-time Error regarding BOF or EOF

    Anyway, I figured out the problem. Thanks for the help!

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