Mysterious value added to text box

Dave,

this is interesting as general information, but can it also help with data validation?

Henry

no. just highlighting potential uses for Boolean "arithmetic".


the underlying problem is that vba syntax is quite restrictive in some ways.

so you can't say
dim a,b,c as integer

(well you can, but what it ACTUALLY does is declares a and b as VARIANTS, and c as an integer, which fact can again introduce unwanted side effects into your app.)

you have to say
dim a as integer
dim b as integer
dim c as integer

you can't say this to initialise a variable. no tricks on this one - you can't do it.
dim a as integer =123

and you can't say
if a = 1 or 2 or 3
(well you can, but as you realised it doesn't mean
if a=1 or if a =2 or if a =3)

if means
if a = (1 or 2 or 3), and (1 or 2 or 3) is actually a fairly obscure Boolean expression, as already explained.
 
Mark,

Thanks for explaining the lines I was confused about.

Users will enter data once and possibly return to it if the Quality Control reader flags a wrong entry. Otherwise, it’s a one-off. For another project, I may need to know about bundling set-up work for every record loaded into a single routine that can be called when a new record loads and calling it when data changes in the form. I’m not sure what that would entail. Would it be a set of instructions at the form level?

I came up with a different solution to the problem, which I think is simpler, since I already have code to make text boxes invisible depending on the data entered in preceding text boxes. Following your suggestion, I changed the Enabled property for TR_3 to False. Then I and used the after update event in TR_2 to change TR_3 to True if the value entered in TR_2 calls for an entry there. Otherwise it remains not enabled, and no invalid data can be entered.

Again, thanks for your patience and for your really clear answers,

Thanks Dave, and Mark, too, for your explanation of Boolian arithmetic in Access. It's not anything I, and I suspect many others, would have guessed, and it's fascinating. Now I want to read up on it. Any suggestions as to where?

Henry
 
Well, you can google "bitwise math" and go from there.

You can also look at places in known object models that use this approach, and for that take a look in the object browser at the second parameter of the MsgBox() function. See how you can bundle up options to change the appearance of the MsgBox buttons?

Code:
MsgBox "Hey world!", [COLOR="Red"]vbYesNo Or vbQuestion Or vbDefaultButton2[/COLOR], "Bitwise Parameter Test"
 
I googled it, and I took a look at the Wikipedia article and a tutorial for C++. It will clearly take some time and concentration, but a whole new world is opening.

Thanks again,

Henry
 
Well, you can google "bitwise math" and go from there.

You can also look at places in known object models that use this approach, and for that take a look in the object browser at the second parameter of the MsgBox() function. See how you can bundle up options to change the appearance of the MsgBox buttons?

Code:
MsgBox "Hey world!", [COLOR="Red"]vbYesNo Or vbQuestion Or vbDefaultButton2[/COLOR], "Bitwise Parameter Test"

Mark. with regard to the msgbox arguments, I use plus, rather than or. I didn't appreciate you could use or.

you get strange results with multiple icons.

msgbox "text", vbquestion + vbinformation
I just tried or, and it still doesn't work
msgbox "text", vbquestion or vbinformation

I guess the msgbox values are just single bits for the most part, so "or" and "plus" do the same thing, but having two icons causes problems.

msgbox "text", vbquestion or vbinformation or vbyesno just gives an OK!
 
Msgbox "Hello", 1 or 2 or 3
gives Yes/No/Cancel which is the same as vbYesNoCancel (which equals 3)

The same for 1 or 2
 
Dave:
I think "+" and "Or" should both work here. I bet you are getting problems because you are using vbQuestion + vbExclamation, which are mutually exclusive, right? One shows the blue question mark, one shows the yellow exclamation point, so you would never use both of those at once. Try settings that would normally be used together, like
Code:
vbYesNo + vbDefaultButton2 + vbQuestion
 

Users who are viewing this thread

Back
Top Bottom