Connecting Tech Pros Worldwide Forums | Help | Site Map

EOF and BOF Errors

Newbie
 
Join Date: Feb 2007
Posts: 2
#1: Feb 8 '07
Part of the coding is listed below but when i run this it comes back with EOF and BOF error (Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record)

Error occurs on the line override = rsc("override") am new to programing and not sure where i would need to fix this error or what i would have to do.

The person we had do this is no longer working with us and the program to best of my understanding was built using Visual Basic 4.0

Would appreciate any help that you may give me.

Lloyd



'==========================='
' UPDATE BUTTON PUSHED '
'==========================='

Private Sub Command3_Click()

product_name = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 0)


If discount_check.Value = 0 Then


Set rsc = CreateObject("adodb.recordset")
rsc.Open "select * from products where product_name='" & product_name & "'", strDSN, 3, 1

override = rsc("override")

If rsc("discount_this") = "1" Then
discount_rate = "0"
Else
discount_rate = glb_discount
End If
rsc.Close

If glb_wholesaleid <> "" And override <> "" Then
discount_rate = override
End If

txt_discount.Text = discount_rate

If txt_discount.Text = "" Then
txt_discount.Text = glb_discount
End If


Else
txt_discount.Text = 0
End If


If txtDataDrop.Text = "" Then
show_alert "PRODUCT"
txtDataDrop.SetFocus
Exit Sub
End If

If txtQuantity.Text = "0" Or txtQuantity.Text = "" Then
show_alert "QUANTITY"
txtQuantity.SetFocus
Exit Sub
End If

If txtWholesaler.Text = "" Then

If txt_firstname.Text = "" Then
show_alert "FIRST NAME"
txt_firstname.SetFocus
Exit Sub
End If

If txt_lastname.Text = "" Then
show_alert "LAST NAME"
txt_lastname.SetFocus
Exit Sub
End If

If txt_address.Text = "" Then
show_alert "STREET ADDRESS"
txt_address.SetFocus
Exit Sub
End If

If txt_city.Text = "" Then
show_alert "CITY"
txt_city.SetFocus
Exit Sub
End If

If txt_state.Text = "" Then
show_alert "STATE"
txt_state.SetFocus
Exit Sub
End If

If txt_zip.Text = "" Then
show_alert "ZIP CODE"
txt_zip.SetFocus
Exit Sub
End If

End If


If MSHFlexGrid1.Row > 1 And product_name <> "" Then
MSHFlexGrid1.RemoveItem (MSHFlexGrid1.Row)
MSHFlexGrid1.Refresh
MSHFlexGrid1.Row = 1
Else
Command1.Enabled = False
End If


If txtPrice_manual.Text <> "" Then
product_price = CDbl(txtPrice_manual.Text)
t_price = product_price
Else
product_price = txtPriceHidden.Text
t_price = txtPriceHidden.Text
End If

If t_price = "0.00" Then
t_price = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 7)
End If


On Error Resume Next

If t_price = "" Then t_price = Round(txtPrice_manual.Text, 2)
the_price = CDbl(t_price * txtShipped.Text)


If txtWholesaler.Text <> "" Then

On Error Resume Next

is_wholesale = "YES"
wholesale = txtWholesaler.Text

Set rs = CreateObject("adodb.recordset")
wholesale = Split(wholesale, " ")
wholesaler_id = wholesale(1)
wholesale = Replace(wholesale, "'", "''")
rs.Open "select * from users where user_id = " & wholesaler_id, strDSN, 3, 1

If Not rs.EOF Then
wholesale_discount = rs("discount")
wholesale_id = wholesaler_id
wholesale_taxid = rs("tax_number")
End If

rs.Close
Set rs = Nothing

End If

iburyak's Avatar
Expert
 
Join Date: Nov 2006
Posts: 1,017
#2: Feb 8 '07

re: EOF and BOF Errors


It looks like record with this name wasn't found
Put this code before line that gives you an error which just checks if actual record was found and exists if not.
[PHP]
IF rsc.bof and rsc.eof then
Set rs = Nothing
Exit sub
End if
override = rsc("override")[/PHP]

I am not sure of your business rules but it might be the case where user hits an update button when actually needed insert. If you have insert button you can call it instead from update button like this:
[PHP]
IF rsc.bof and rsc.eof then
Set rs = Nothing
call InsertButtonName_click
Exit sub
End if
override = rsc("override")[/PHP]
Newbie
 
Join Date: Feb 2007
Posts: 2
#3: Feb 8 '07

re: EOF and BOF Errors


Hi, thanks for the code you replied us. It seems to have fixed the problem of it erroring out, however, by entering that code, we cannot apply any discounts to the item we are trying to add.

To sum it up, the code you gave us let us insert the new item to the customers order, however we cannot override manually the discount given on a particular item.

Right now we may assume that the employee working on this program has left out some key items to make the prorgram complete, but its hard to say since I do not know how exactly he coded this particular portion.

If you have any other suggestions it would be appreciated.
Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#4: Feb 9 '07

re: EOF and BOF Errors


I won't discuss the EOF/BOF thing, as Iburyak has dealt with that. As for the rest...

I think you need to pinpoint why the name doesn't match. In this
Expand|Select|Wrap|Line Numbers
  1. rsc.Open "select * from products where product_name='" & product_name & "'", strDSN, 3, 1
  2. override = rsc("override")
you need to investigate where (or whether) the variable product_name was populated, and why it doesn't match what you expected to find in field [products].[product_name].

If you find that it does appear to match, consider the possibility that the match might be case-sensitive. (I'm not at all certain that is even possible, though).

Also, if I might be permitted a personal observation, I think it is unnecessarily confusing to use identical names for database fields and variables in this way (Eg. product_name). :) I realise you're just trying to take over someone else's unfinished code, but I think that's worth keeping in mind.

And one last point. When posting code, please put [C O D E] and [/ C O D E ] tags around it. (Remember to leave out the spaces I embedded in the tags here, and do a "Preview Post" before submitting, to see whether it worked.)
iburyak's Avatar
Expert
 
Join Date: Nov 2006
Posts: 1,017
#5: Feb 9 '07

re: EOF and BOF Errors


Quote:

Originally Posted by ultraclassic

Hi, thanks for the code you replied us. It seems to have fixed the problem of it erroring out, however, by entering that code, we cannot apply any discounts to the item we are trying to add.

To sum it up, the code you gave us let us insert the new item to the customers order, however we cannot override manually the discount given on a particular item.

Right now we may assume that the employee working on this program has left out some key items to make the prorgram complete, but its hard to say since I do not know how exactly he coded this particular portion.

If you have any other suggestions it would be appreciated.

Unfortunately I can give you direction and suggestions but you are the one who have to make it work. I’ll try to give you one more advice:

Try to do this:

[PHP]

Set rsc = CreateObject("adodb.recordset")

RestartDiscount:
rsc.Open "select * from products where product_name='" & product_name & "'", strDSN, 3, 1


IF rsc.bof and rsc.eof then
call InsertButtonName_click
GoTo RestartDiscount
End if

override = rsc("override") [/PHP]

What I do here call insert command and then redirect code to start discount update all over again. Now it should find newly inserted record and proceed with discount, if of cause I didn't miscalculate it, due to inability to test. It is only my guess.

Good Luck.
Reply