Code behaves different for users and admin

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a form that contains a checkbox field. I have written code that
disables the check box in a given record if one of the other fields contains
a null value. It works for my users, but it doesn't work for admin. Why might
this be? Users are granted open/run permissions and admin has all permissions
to this form, but why is the code affected?

Thanx to any who can help,

Ripper T
 
(a) Show us the disabling code.

(b) How "doesn't it work"?

Are you testing on the same records with each user, or is Admin & the
other user using different records?

IOW, what mnakes you think it is the user (not the records) which are
causing the problem?

TC
 
The code is in the on_current event of the subform:

If myField =" " Then
myCheckbox.enabled = false

I don't think the users are causing the poblem, I'm saying that when the
users are logged on, the checkbox is diabled if myField is blank. But if I am
logged on as admin, the check box is remains enabled in every case. Yes, I am
testing on the exact records as the users. I have checked the property sheet
for the checkbox and made sure the field is not locked. The subform is in
datasheet view.

Thanx for the response,

Ripper

BTW, what does IOW stand for?
 
RipperT said:
The code is in the on_current event of the subform:

If myField =" " Then
myCheckbox.enabled = false

You are testing to see if myField is exactly 1 space character. That is
not what a "blank field" is! The if-test you have written would never
be true in normal circumstances. And if it *was* ever true, it would
never set the checkbox back to Enabled!

Here's what you need:

myCheckbox.enabled = (nz (myField, "") <> "")

Note that each of the two "" sequences, is two adjacent double-quote
marks, with *no spaces* between them.

(snip)
BTW, what does IOW stand for?
In other words.

Cheers,
TC
 
My bad. I mistyped in my response. My actual code has no space between the
quotes:

If myField ="" Then
myCheckbox.enabled = false

Sorry about that.
myCheckbox.enabled = (nz (myField, "") <> "")

Can you spell out this code for my less-than-average brain? I looked up Nz
function in the VBE and I just don't get it. What does each part do? Does it
address getting the checkbox set back to enabled, and if so, how?

Many thanx,

Ripper
 
In brief:

"Blank" usually means, a zero-length string: ""

*Fields* (as opposed to *controls*) can often be NULL, which is a
special value which is effectively blank, but which can *not* be
detected by testing for an empty string.

I suspect that the thing you have named myField, is actually a control
- not a field. But to be safe, I used the nz() function to say: "check
the value of that thing, but if it is NULL, return an empty string
instead".

The statement that I suggested for your On_Current event, is basically
saying: "Set the value of the Enabled property of the checkbox, to True
if the value in myField is not blank and not NULL, or False otherwise
(ie. when it *is* blank or NULL).

Sorry, but I'm trying to drain one of my own swamps of alligators at
the moment, so I don't have time to reply again today - unless you can
tell me whether it is safe to hardcode the CLSIDs of GDI+ encoders :-)

HTH,
TC
 
You've been temendously helpful, thank you.

CLSID'S = dangerous
Alligators = more dangerous

Have a hot toddy, go to bed, pick up where you left off tomorrow.
Good luck.

Ripper
 
I've inserted your code and it makes no difference. The checkbox remains
enabled for the administrator and disabled for the user. Any ideas?

Thanx again,

Rip
 
The code that I suggested makes no reference to whether the user is or
is not an administrator. It only considers whether the value of
myField, is or is not an empty string or NULL.

Are you sure that you have:
- copied the code correctly,
- placed it in the Form_Current event, and
- have no *other* code that is referencing the checkbox enabled
property?

Add the following statement immediately before the one I suggested:

msgbox "<" & nz(myField,"") & ">"

That message should display as you move from record to record. If the
message is <>, the value of myField is an empty string or NULL, and the
next line of code (the one that I suggested before) will disable the
checkbox. Conversely, if the message is anything else, the value of
myField is *not* an empty string or null, and the next line will enable
the checkbox.

HTH,
TC

HTH,
TC
 
Back
Top