zmbd 5,501
Expert Mod 4TB
Unbound form and two unbound text boxes:
z_ctrl_txt_HistoryLogVol
z_ctrl_txt_HistoryLogPage
The form is unbound as there must be validation steps performed against the other data entries and there is a "sign-off" PIN that the tech must enter to confirm that the information has been reviewed.
In the lab there are multiple logbooks,hence the LogVol,
and ofcourse, the pages therein, LogPage
It makes no sense to have either one or the other filled unless they are both filled (a volume without a page or a page without a volume... either way , useless).
So this is what I've been using to check to see if both are filled: - If (Me!z_ctrl_txt_HistoryLogVol & "" = "") Xor (Me!z_ctrl_txt_HistoryLogPage & "" = "") Then
-
'naughty naughty code here
This works like a charm and I've used this type of construct many times to check that numeric-label are set and so forth...
The question is, is there a better way?
Ahh. That also changes the thrust of the question somewhat ;-)
In that case though, where you want to ensure there are no embedded spaces, as well as no upper-case alphas, I would use : - Dim strX As String, strY As String
-
-
strX = LCase(Replace(Nz([X], ""), " ", ""))
-
If strX > "" Then [X] = strX
-
strY = LCase(Replace(Nz([Y], ""), " ", ""))
-
If strY > "" Then [Y] = strY
-
If (strX = "") Xor (strY = "") Then ...
12 1373 NeoPa 32,556
Expert Mod 16PB
So, you want to find when either one or the other, but not both, of the controls is Null?
I would say : - If IsNull(X) Xor IsNull(Y) Then
-
'etc.
Very much as you have it already. I can't think of a better concept, but I (personally) would make the checks us IsNull() instead of the other.
zmbd 5,501
Expert Mod 4TB
I had originally started with just the isnull(); however, if a user enters a value in the control, tab's out, and then back into the control finally clears it (delete key) or enters just the spacebar then the isnull() doesn't catch this fact; however, this construct appears to catch this action.
Also, when I reset the form the value is reset to an empty-string and not a null value.
NeoPa 32,556
Expert Mod 16PB
I'm surprised. Especially surprised that what you have would check for a space (" ") value. Maybe TextBox controls take the settings from the field and allow empty strings if the field does. That might at least explain why an empty control could have a ZLS value rather than the more usual Null.
zmbd 5,501
Expert Mod 4TB
It's a funny report:
Customer Name
addresss
etc
report
Group header with sample id
"test1" "result" "Vol ___" "Pg 2013"
"test2" "result" "Vol 15" "Pg ____"
Where the underscors would be spaces or missing information; thus, one without the other is worse that useless... if the auditor comes in, we HAVE to be able to find the "wet work" as the original point of entry.
SO I had to test for Null, spaces, ZLS. The nasty is the, lets mess with Z and just hold the spacebar down. Finally solved that, so so so simple, no spaces are allowed! The Volume may be "VOL: ABA1" they may enter "ABA 1" and I just use the replace() to kill all spaces, then test as shown for Null and ZLS :) - that was one of those "duhhhh" moments too.
NeoPa 32,556
Expert Mod 16PB
All makes sense Z.
If spaces and ZLS both possible entries, as well as Nulls, then I'd (personally) use :
A purely optional suggestion, of course.
zmbd 5,501
Expert Mod 4TB
That's certainly a much better way of getting rid of the unallowed.
Now to test, if one is filled then both variation on a theme
by using the trim(NZ()) we would get: - if (trimedvol="") XOR (trimedpage="") then
-
'userfeedback for required entry
-
'set focus to missing entry
or is there a better logic?
zmbd 5,501
Expert Mod 4TB
I just tried the Trim(NZ()), works ok with the leading and trailing spaces; however, doesn't account for those times when the user likes the spacebar inbetween ("AA________________123" where the underscore represents spaces")
So am I back to basically the same logic?
NeoPa 32,556
Expert Mod 16PB
Would you ever want to 'account' for that scenario Z?
It seems to me that if an operator entered spaces within a word then that's what they intend to enter. It'll be a long time before code can psychicly determine what an operator intended to enter. Until that time, removing spaces from the middle of an entry is fundamentally illogical.
As for your basic logic. I believe you had that right from the get-go. I was never going to improve on that.
zmbd 5,501
Expert Mod 4TB
Ahhh, here's the logic: By SOP, the nomenclature of the logbook volume names is to be alphanumeric only without the use of spaces, periods, dashes, underscore, or other forms of puncuation. Furthermorre, that upper and lowercase will be treated the same. Thus, when the user enters a space, the space violates the SOP/business rules. Ofcourse, with page numbers, it wouldn't make sense (in the US) to have page thirty enterd as "3_0" or page 100 enterd as "1_0_0_" which we had one tech that would do that just to see if the program would crash!
NeoPa 32,556
Expert Mod 16PB
Ahh. That also changes the thrust of the question somewhat ;-)
In that case though, where you want to ensure there are no embedded spaces, as well as no upper-case alphas, I would use : - Dim strX As String, strY As String
-
-
strX = LCase(Replace(Nz([X], ""), " ", ""))
-
If strX > "" Then [X] = strX
-
strY = LCase(Replace(Nz([Y], ""), " ", ""))
-
If strY > "" Then [Y] = strY
-
If (strX = "") Xor (strY = "") Then ...
zmbd 5,501
Expert Mod 4TB
Very good and actully very close to what I have in use. I use the UCASE as we've found this easier to read; however, lowercase is allowed. I have other validations too such as no letters "i" and "o" as they can look like the numbers one and zero depending on the font etc...
Thank you for letting bounce this off the forum. Not being a professional programmer it's nice to be able to double check my logic!!!!!
-z
NeoPa 32,556
Expert Mod 16PB
Any time :-)
Frankly, for you, you could call me any time if that could help.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matt Price |
last post by:
A super simple question:
is there a standard trick to get the url of the current page in a cgi
script, or the url from which form data has been passed?? I want to
embed the name of the current...
|
by: Niklaus |
last post by:
Hi,
Can someone point out what is wrong with this code ? How can i make
it better optimize it. When run it gives me seg fault in linux. But
windows it works fine(runs for a long time).
Do we...
|
by: Phl |
last post by:
hi,
just wondering which way of coding is considered better?
This style where the two returns aren't interconnected by an else
statement in the if seems to be very popular these day, where use...
|
by: Eric Renken |
last post by:
OK, I have a form with a menu and a tool bar. In the Menu I have a File
menu that contains a "Exit" item. When I click this Exit item. I have an
event wired to:
mnuFile.DropDown.ItemClicked
...
|
by: lnzju |
last post by:
main(_){for(--_;putchar(_++-1););}
|
by: Protoman |
last post by:
Which is better for general-purpose programming, C or C++? My friend
says C++, but I'm not sure. Please enlighten me. Thanks!!!!!
|
by: cowznofsky |
last post by:
We often see a GUI feature that shows 2 list boxes and a series of
buttons in between them with "<", "<<", ">>", and ">" options.
Is there a name that is commonly used for this?
|
by: JoeC |
last post by:
I am working on another game project and it is comming along. It is an
improvment over a previous version I wrote. I am trying to write
better programs and often wonder how to get better at...
|
by: Anton Vredegoor |
last post by:
Since a few days I've been experimenting with a construct that enables
me to send the sourcecode of the web page I'm reading through a Python
script and then into a new tab in Mozilla. The new tab...
|
by: David |
last post by:
http://msdn2.microsoft.com/en-us/library/bew39x2a(VS.80).aspx
I was looking at above link and I just don't see the advantage of this. The
main thread is just stopping and waiting for each of the...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: 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,...
|
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...
| |