473,799 Members | 2,786 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

before update - validating potential new data

Hi all

i would like to thank Darryl, he helped me a lot

now i have another problem

LeBayNum is the primary key in [tblListedItems]
relates to SeBayNum in tblSold
relationship is one LeBayNUM to many SeBayNUM

duplicate numbers are not allowed, so
i am trying to bypass access error handling with the following
procedure in the before update event of the textbox LeBayNUM

Private Sub LeBayNUM_Before Update(Cancel As Integer)
On Error GoTo ErrorHandler
Dim Cnn As New ADODB.Connectio n
Dim Rst As New ADODB.Recordset
Set Rst = New ADODB.Recordset
Dim Response As Integer
If IsNull(Forms![frmlisted_3]![frmllisteditems
subform].Form![LeBayNUM]) Or Forms![frmlisted_3]![frmllisteditems
subform].Form![LeBayNUM] = " " Then
Response = MsgBox("eBay Number Must be Entered!" & vbCrLf & "Do You
Want to Cancel the Entry?", vbYesNo)
If Response = vbNo Then
Cancel = True
GoTo done
Else
Forms![frmlisted_3]![frmllisteditems
subform].Form![LeBayNUM].Undo
Cancel = True
GoTo done
End If
Else
If (Forms![frmlisted_3]![frmllisteditems subform].Form![LeBayNUM]
<> Forms![frmlisted_3]![frmllisteditems
subform].Form![LeBayNUM].OldValue) Or
IsNull(Forms![frmlisted_3]![frmllisteditems
subform].Form![LeBayNUM].OldValue) Then

Cnn.Open CurrentProject. Connection
Rst.Open "Select [LeBayNUM] from TblListedItems" , Cnn,
adOpenForwardOn ly, adLockOptimisti c

If Not Rst.EOF Then
Response = MsgBox("Duplica te eBay Number!" & vbCrLf & "Do You Want
to Cancel The Entry?", vbYesNo)
If Response = vbYes Then
Forms![frmlisted_3]![frmllisteditems subform].Form![LeBayNUM].Undo
End If
End If
Rst.Close
Set Rst = Nothing
End If
End If

GoTo done

ErrorHandler:
MsgBox Err.Description
done:
End Sub

i cant get i to work
this is the error message:
the database has been placed in a state by user 'admin' on machine
'ibm-a2423412' that prevents it from being opened or locked

Nov 13 '05 #1
1 3549
"gbb0330" <gb*****@gmail. com> wrote
LeBayNum is the primary key in [tblListedItems]
relates to SeBayNum in tblSold
relationship is one LeBayNUM to many SeBayNUM

duplicate numbers are not allowed, so
i am trying to bypass access error handling with the following
procedure in the before update event of the textbox LeBayNUM

the database has been placed in a state by user 'admin' on machine
'ibm-a2423412' that prevents it from being opened or locked

*I think* the problem is that you are attempting to undo the new value, and
use Cancel=True. My own BeforeUpdate events are pretty simple affairs, that
check the value, and if it's not valid, then Cancel=True. No undo.

Now, you've also got this code in ab event associated with LeBayNUM, which
looks like a textbox in a subform. But your code appears to be referencing
the textbox later as Forms![frmlisted_3]![frmllisteditems
subform].Form![LeBayNUM] rather than just Me.LeBayNUM. I really have no
idea what effect that wiould have, but if that is what you are doing, by all
means simplify it.

Try this:

Private Sub LeBayNUM_Before Update(Cancel As Integer)
On Error GoTo ErrorHandler
Dim Cnn As ADODB.Connectio n ' Don't use New here
Dim Rst As ADODB.Recordset ' Don't use New here
SetSet Cnn = CurrentProject. Connection ' changed Cnn open
Set Rst = New ADODB.Recordset
Dim Response As Integer

If IsNull(Me.LeBay NUM) Or Me.LeBayNUM = " " Then
Response = MsgBox("eBay Number Must be Entered!" & _
vbCrLf & "Do You Want to Cancel the Entry?", vbYesNo)
If Response = vbYes Then
Cancel = True
End If
Else
If (Me.LeBayNUM] <>Me.LeBayNUM.O ldValue) Or _
IsNull(Me.LeBay NUM.OldValue) Then
' Specify Source separately - easier to read
Rst.Source = "Select [LeBayNUM] from TblListedItems"
' Add adCmdText parameter for SQL strings - faster
' Use adCmdTable for tables
' Only need ReadOnly for this - no updates - faster
Rst.Open , Cnn, adOpenForwardOn ly, adReadOnly, adCmdText
If Not Rst.EOF Then
Response = MsgBox("Duplica te eBay Number!" & vbCrLf & _
"Do You Want to Cancel The Entry?", vbYesNo)
If Response = vbYes Then
Cancel = True
End If
End If
Rst.Close
End If
End If
Set Rst = Nothing ' needs to be here to always execute
GoTo done
ErrorHandler:
MsgBox Err.Description
done:
End Sub

Darryl Kerkeslager
Nov 13 '05 #2

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

Similar topics

3
2441
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
2711
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
2126
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
1441
by: gbb0330 | last post by:
Hi all i have a textbox on a Sub Form bound to a table 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
4
4290
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
5611
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
1293
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
9543
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10488
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
10029
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
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
5467
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
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
3
2941
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.