|
-
Sep 2nd, 2006, 09:08 PM
#1
Thread Starter
Lively Member
[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:
Private Sub LoadData()
Dim psql As String
Set cnn = New ADODB.Connection
cnn.Mode = adModeReadWrite
cnn.Open ("INVENTORY")
Set rec = New ADODB.Recordset
rec.CursorType = adOpenKeyset
rec.LockType = adLockOptimistic
psql = "select * from tblCustomerInformation "
psql = psql + " where CustNo = " + Trim(Str(Id))
rec.Open psql, cnn, , , 1
*Text2.Text = IIf(IsNull(rec!Fname), "", rec!Fname)
Text1.Text = IIf(IsNull(rec!Lname), "", rec!Lname)
Text5.Text = IIf(IsNull(rec!ContactNo), "", rec!ContactNo)
Text8.Text = IIf(IsNull(rec!EmailAdd), "", rec!EmailAdd)
Text14.Text = IIf(IsNull(rec!Birthday), "", rec!Birthday)
'Text9.Text = IIf(IsNull(rec!Gender), "", rec!Gender)
Text9.Text = IIf(IsNull(rec!Address), "", rec!Address)
Text13.Text = IIf(IsNull(rec!Comment), "", rec!Comment)
End Sub
The line with the asterisk is highlighted when debugged.
Last edited by sirkeled; Sep 3rd, 2006 at 04:28 AM.
-
Sep 2nd, 2006, 09:11 PM
#2
Re: Run-time Error regarding BOF or EOF
VB Code:
rec.Open psql, cnn, , , 1
[color=red]If [color=red]Not[/COLOR] rec.[color=red]EOF[/COLOR] Then[/COLOR]
*Text2.Text = IIf(IsNull(rec!Fname), "", rec!Fname)
Text1.Text = IIf(IsNull(rec!Lname), "", rec!Lname)
Text5.Text = IIf(IsNull(rec!ContactNo), "", rec!ContactNo)
Text8.Text = IIf(IsNull(rec!EmailAdd), "", rec!EmailAdd)
Text14.Text = IIf(IsNull(rec!Birthday), "", rec!Birthday)
'Text9.Text = IIf(IsNull(rec!Gender), "", rec!Gender)
Text9.Text = IIf(IsNull(rec!Address), "", rec!Address)
Text13.Text = IIf(IsNull(rec!Comment), "", rec!Comment)
[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
-
Sep 2nd, 2006, 09:15 PM
#3
Thread Starter
Lively Member
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.
-
Sep 2nd, 2006, 09:20 PM
#4
Hyperactive Member
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 
-
Sep 2nd, 2006, 09:32 PM
#5
Re: Run-time Error regarding BOF or EOF
on a sidenote, you can also just do:
VB Code:
Text2.Text = rec!Fname & ""
Text1.Text = rec!Lname & ""
'etc.
instead of all those IsNull checks
-
Sep 3rd, 2006, 04:22 AM
#6
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|