Hi,
I'm a novice with VB and I've written this pretty simple script, but
for the life of me, I can't get the last bit of the script to work. It
should compare the value entered by the user under the BeforeUpdate
event and compare it to the value in the main form. It's doing that
just okay, but when I want to reset the value using the original value
(from the main form), it seems the BeforeUpdate event prevents me from
changing it back. What could the problem be here? This should be
quite simple I suppose. The script I have is as follows and runs from
the SubForm's BeforeUpdate. Your help here would be GREATLY
appreciated.
Public Sub TO_CHAINAGE_Bef oreUpdate(Cance l As Integer)
'If the user updates a TO CHAINAGE value, this script will warn the
user that
'the value entered is higher than the maximum value set for the road
Dim MaxLenDef As Double
Dim MaxLenCondInv As Double
'Assign the length value from the definition table, representing the
maximum value
MaxLenDef = Forms!frmCOND_C OMBO.[LENGTH].Value
'Get the value edited by the user
MaxLenCondInv = Forms!frmCOND_C OMBO!subCOND_NE W.Form![TO
CHAINAGE].Value
'Prompt the user if the value is higher than the definition length
If MaxLenCondInv > MaxLenDef Then
MsgBox "The value entered exceeds the maximum length value for this
road:" _
& vbNewLine & vbNewLine & " " & MaxLenDef & "
Kilometres" & vbNewLine _
& vbNewLine & "Please request a ROAD DEFINITION change from your
Database Administrator."
'Assign the old value back to the cell
Forms!frmCOND_C OMBO!subCOND_NE W.Form![TO CHAINAGE].Value =
MaxLenDef
End If
End Sub 2 1726
You can not assign a value during the beforeupdate event. Impossible.
You are validating the input and you can simply cancel the new value with a line like
Cancel=true
This will prevent the user from leaving the control until the input is OK.
Hitting escape will put back the previous value, so you could 'tell' this to the users.
If you really need to reset the value, you can to use the Afterupdate-event.
I would immediately save the record after that to prevent an 'Escape' with the Escape key
HTH
Arno R
<de**********@y ahoo.com> schreef in bericht news:11******** **************@ j33g2000cwa.goo glegroups.com.. . Hi, I'm a novice with VB and I've written this pretty simple script, but for the life of me, I can't get the last bit of the script to work. It should compare the value entered by the user under the BeforeUpdate event and compare it to the value in the main form. It's doing that just okay, but when I want to reset the value using the original value (from the main form), it seems the BeforeUpdate event prevents me from changing it back. What could the problem be here? This should be quite simple I suppose. The script I have is as follows and runs from the SubForm's BeforeUpdate. Your help here would be GREATLY appreciated. Public Sub TO_CHAINAGE_Bef oreUpdate(Cance l As Integer) 'If the user updates a TO CHAINAGE value, this script will warn the user that 'the value entered is higher than the maximum value set for the road Dim MaxLenDef As Double Dim MaxLenCondInv As Double 'Assign the length value from the definition table, representing the maximum value MaxLenDef = Forms!frmCOND_C OMBO.[LENGTH].Value 'Get the value edited by the user MaxLenCondInv = Forms!frmCOND_C OMBO!subCOND_NE W.Form![TO CHAINAGE].Value 'Prompt the user if the value is higher than the definition length If MaxLenCondInv > MaxLenDef Then MsgBox "The value entered exceeds the maximum length value for this road:" _ & vbNewLine & vbNewLine & " " & MaxLenDef & " Kilometres" & vbNewLine _ & vbNewLine & "Please request a ROAD DEFINITION change from your Database Administrator." 'Assign the old value back to the cell Forms!frmCOND_C OMBO!subCOND_NE W.Form![TO CHAINAGE].Value = MaxLenDef End If End Sub
Hi Arno,
I tried your advice and started playing around with this and found that
the best option is using GotFocus and LostFocus. This worked fine, but
then whenever the user clicked on a blank cell (the "Add New" record)
it also referenced to it and failed because the cell is blank, but when
I used an If Then statement to check whether the cell is blank, before
storing the value, it workd like a charm! Although I didn't use you
suggestion exactly, it helped by just looking at it from a different
angle.
Thanks mate.
Dean Carstens
Scott Wilson Plc
DFID Support to Feeder Roads
Ghana This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: alexis |
last post by:
Hi,
In a form I have the curent date
<input name="datetoday" type="hidden" value="<? echo date("d/m/Y"); ?>">
and
<input type=text name="datebox" size=15>
The date format is d/m/Y (day/month/year) in both case
Now my problem is that i want to know if 'datebox' is valid, that means
after 'datetoday'.
|
by: pepino13 |
last post by:
Hello,
I have a a form called frmMissyFact, I have copied this form and
called it frmMissyFactBackup which reads data from a backup database
of the week before. I brought frmMissyFactBackup into frmMissyFact as
a subform. What I am trying to do is compare each control value from
frmMissyFact to that of frmMissyFactBackup and if the controlvalue is
different change the backcolor to Yellow of the control so the user
looking at it knows...
|
by: John Michael |
last post by:
I have a form that has a subform that has a subform.
The subform loads a record based on a combo lookup box in the main form.
I'm trying to set a value in the subform based on a value in a subform of
the subform.
the main Form is called
Subform is called
Subform in the subform is called
|
by: Einar |
last post by:
Hi,
I wonder if there is a nice bit twiddling hack to compare a large
number of variables?
If you first store them in an array, you can do:
for (i = 0; i < n; i++) {
if (array != value) {
/* array differs from value, do something*/
|
by: Sam |
last post by:
Hi Everyone,
I have a stucture below stored in an arraylist and I want to check user's
input (point x,y) to make sure there is no duplicate point x,y entered
(string label can be duplicated). Is there a way to compare the new input
point x,y without having to a loop and compare the whole object in the array
list. I can't use the indexof method because it would compare the whole
object.
Public Structure
| |
by: Lamis |
last post by:
Hi,
what is the best way to compare 2 haschtables contatining objects. the
objects has 2 property, name & value. I need to print out the differences
--
LZ
|
by: Ecohouse |
last post by:
I have a main form with two subforms. The first subform has the child
link to the main form identity key.
subform1 - Master Field: SK
Child Field: TrainingMasterSK
The second subform has a master-child link to the first subform.
subform2 - Master Field: subTrainingModule.Form!TrainingModuleTopicSK
Child Field: TrainingModuleTopicSK
|
by: super.raddish |
last post by:
Greetings,
I am relatively new to, what I would call, advanced XSLT/XPath and I
am after some advice from those in the know. I am attempting to figure
out a mechanism within XSLT to compare the difference between two
source documents and output node-sets which are "different" (changed
or new) to new XML files using xsl:result-document
To describe the problem I have provided some example data below along
with my a portion of my current...
|
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= |
last post by:
Hi
I have a Container that is an an Array List of Class
Each ArrayList element can be the class or a another ArrayList of Class
So there the ArrayList could look like
Element 1 - Class
Element 2 - Class
Element 1 - ArrayList Of Class
Element 1 - Class
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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,...
|
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();...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |