473,809 Members | 2,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

before update - validating potential new data?

Hi all

i have a textbox [LeBayNum] on a Sub Form [frmllisteditems subform]
bound to a table [tblListedItems]

i want to make sure there are no duplicate eBay numbers entered in the
textbox

so here is my code in the before update event procedure of the textbox
LeBayNUM

On Error GoTo errorhandler
Dim Cnn As ADODB.Connectio n
Dim Rst As ADODB.Recordset

Set Rst = New ADODB.Recordset
Dim response As Integer

If (Me![LeBayNUM] <> Me![LeBayNUM].OldValue) Or
IsNull(Me![LeBayNUM].OldValue)_ Then
Cnn.Open CurrentProject. Connection
Rst.Open "SELECT * from TblListedItems where [LeBayNUM]= """ &
Me!LeBayNUM &_ """", Cnn, adOpenForwardOn ly, adLockReadOnly
If Not Rst.EOF Then
response = MsgBox("Duplica te eBay Number!" & vbCrLf & "Do You want to
Cancel_ the Entry?", vbYesNo + vbCritical, "Duplicate eBay Number")
If response = vbYes Then
[LeBayNUM].Undo
End If
End If
Rst.Close
Set Rst = Nothing
End If
GoTo done
Set Rst = Nothing
GoTo done
errorhandler:
MsgBox Err.Description
done:
End Sub
the error message that i get every time the code is executed is
Object variable or With block variable not set
any help will be appreciated
thank you in advance

Nov 13 '05 #1
1 1441
never mind
i got it
here is the correct version, maybe somebody can use it

On Error GoTo ErrorHandler
Dim Cnn As ADODB.Connectio n
Dim Rst As ADODB.Recordset
Set Cnn = CurrentProject. Connection
Set Rst = New ADODB.Recordset
Dim response As Integer
If (Me.LeBayNUM <> Me.LeBayNUM.Old Value) Or
IsNull(Me.LeBay NUM.OldValue) Then
Rst.Source = "select * from tbllisteditems where [LeBayNUM]= """ &
Me!LeBayNUM & """"
Rst.Open , Cnn, adOpenForwardOn ly, adLockReadOnly, adCmdText
If Not Rst.EOF Then
response = MsgBox("Duplica te eBay Number!" & vbCrLf & "Do you Want to
Cancel the Entry?" & vbCrLf & "If you Click Yes You Will Have to enter
a Different eBay Number" & vbCrLf & "If You Click No, a Duplicate eBay
Number Will be Saved", vbYesNo)
If response = vbYes Then
cancel = True
End If
End If
Rst.Close
End If

Set Rst = Nothing
GoTo done

ErrorHandler:
MsgBox Err.Description
done:
End Sub

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2442
by: PAUL EDWARDS | last post by:
I have a windows form that is bound to a datatable. In VB6 I could just update the field contents and it would be updated in the database, however if I update the text property of the control from code it is 50% chance that the update will make it back to the dataset. If I update the dataset instead of the form, it does not show on the form. Is there a method that should be used?
9
2713
by: Mark | last post by:
Hi there On this page i get some errors when validating: http://www.keyone.nl/lab/beeldlijn/nl/collection.asp The problem is caused by the use of ASP in my pages. This is the code: <a href="winkelwagen.asp?artikelId=<%=artikelId%>&titel=titel%>&prijs=<%=prijs%>"
1
2127
by: Rolan | last post by:
Having tried various permutations of Before Update and well for that matter, After Update, OnExit, OnEnter, etc. and also Locked controls, I'm still unable to obtain the intended results. There are actually two parts of what I'm trying to accomplish, but are interrelated. When one part performs as it should, then upon implementation of the other, conflicts arise and vice versa. A form (frmEvents) is used to logged various events and one...
1
3550
by: gbb0330 | last post by:
Hi all i would like to thank Darryl, he helped me a lot now i have another problem LeBayNum is the primary key in relates to SeBayNum in tblSold relationship is one LeBayNUM to many SeBayNUM
4
4294
by: Wysiwyg | last post by:
I need to validate a form to ensure that all of the fields add up correctly. I can't do this while the user is entering data since validation needs to be done after the entry is completed. What's the "best" way to validate prior to submitting? I could add an onsubmit attribute to the form which executes the validation in Javascript. That way the response doesn't need to be sent before validation takes place. Is this pretty much the way...
5
5613
by: Louis LeBlanc | last post by:
Hey folks. I'm new to the list, and not quite what you'd call a DB Guru, so please be patient with me. I'm afraid the lead up here is a bit verbose . . . I am working on an application that uses very high volume DB transactions - in the order of tens of millions per day . . . Anyway, the current database which will remain nameless, but begins with O and rymes with debacle (sorta), has a problem with high volume work when it comes to...
5
1392
by: pisquem | last post by:
I have a web applicaiton that has a form that is used to update a record from a sql table. This page will load with a value being retrieved from a querystring. The value is from the querystring and a call is made to a WS that returns the record (that is to fill all the fields in the form) which then allows the user to update this record. Not delete or add a new record just update. Having said that, with many different ways to do this,...
3
1294
by: rcoco | last post by:
hi, I've tried to update my database using my datagrid but there is no change. here is the code I'm using: private void Update_dataGrid(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { System.Web.UI.WebControls.TextBox cstaff=new
0
905
by: castlegrpsf | last post by:
I have a win form using VB.NET that needs to set some values prior to updating a SQL database. The values being stored are computed at the time the user is saving the data. It is based on other data fields on the form, that are bound to the data source. Where can I accomplish this. (1) Field validation will not work since not all fields on the form need to be completed prior to saving. (2) Form validation Me.Validate does not seem to...
0
10643
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10378
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10391
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7664
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3862
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.