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
4 2724 iburyak 1,017
Recognized Expert Top Contributor
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]
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.
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 - rsc.Open "select * from products where product_name='" & product_name & "'", strDSN, 3, 1
-
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 1,017
Recognized Expert Top Contributor
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mikey_boy |
last post by:
Hello! Curious if anyone could give me a hand. I wrote this PHP
script with makes a simple connection to a mysql database called
firstdb and just pulls back the results and displays on the...
|
by: Trev |
last post by:
SQL Server 2000 BE, Access 2002 FE.
I want to write a stored procedure, that will among other things log
errors to a table, I want to be able to report a summary of work done
and errors to the...
|
by: Douglas Buchanan |
last post by:
I am using the following code instead of a very lengthly select case
statement.
(I have a lot of lookup tables in a settings form that are selected
from a ListBox. The data adapters are given a...
|
by: doli |
last post by:
Hi,
I have the following piece of code which iterates through the potential
errors:
i =0
For Each error_item in myConn.Errors
DTSPackageLog.WriteStringToLog myConn.Errors(i).Description...
|
by: johnb41 |
last post by:
I have a form with a bunch of textboxes. Each text box gets validated
with the ErrorProvider. I want the form to process something ONLY when
all the textboxes are valid.
I found a solution,...
|
by: Samuel R. Neff |
last post by:
Within the past few weeks we've been getting a lot of compiler errors
in two classes when no errors actually exist. The error always
reports as
Name '_stepResizeRelocator' is not declared.
...
|
by: pat |
last post by:
Hi everyone, I've got an exam in c++ in two days and one of the past
questions is as follows.
Identify 6 syntax and 2 possible runtime errors in this code:
class demo
{
|
by: ImOk |
last post by:
I just have a question about trapping and retrying errors especially
file locking or database locks or duplicate key errors.
Is there a way after you trap an error to retry the same line that...
|
by: clemrock |
last post by:
Help w/ errors.add_to_base between controller and model
Hello,
I'm having trouble in routing some errors between model and
controller. The errors produced in the controller...
|
by: =?Utf-8?B?UmFuZHlz?= |
last post by:
This just started when I updated to sp 1 working on a APS.net, Visual Studio
2008, c# Project.
When I open a project, I get tons of Errors showing in the list 300+
if I double click on them I go...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |