andygriffin
05-26-2002, 07:17 AM
Hi all
Apologies if this is in the wrong forum - the question involves a query and a form.
Brief background - this is some code involving carrying out an action depending on the results of a query to be active on the open event of the main form in the database. The form is not based on a table.
There is a hidden text box on the form which captures the users Windows NT NetID when they open the form.
Inserted into the form is a subform which is based on a query which returns the users information which is stored in a table in the database, and is returned via the stored NetID value on the main form.
What I am trying to do is disable a button if the user's captured NetID does not exist in the table.
What I have tried to use is variations of:
If Me!frmUserinfo!Usernetid Is Null Then
Me!Button1.enabled = False
Else: Me!Button1.enabled = True
End If
The idea behind this is to give everybody access to the database, but only registered users (Entered into a table by admin) will have access to Button1. The idea being that the query determines that the user is not registered because it returns no values (the netid is not found in the table) and so the subform, and specifically the netid field, contains no value.
But I can't get this to work!!
I have tried the following:
If Me!frmUserinfo!Usernetid Is Null Then
Me!Button1.enabled = False
Else: Me!Button1.enabled = True
End If
(this throws an error)
If Me!frmUserinfo!Usernetid = Null Then
Me!Button1.enabled = False
Else: Me!Button1.enabled = True
End If
(this doesn't do anything)
If Me!frmUserinfo!Usernetid = "" Then
Me!Button1.enabled = False
Else: Me!Button1.enabled = True
End If
(this doesn't work)
All help is gratefully appreciated!
Andy.
Apologies if this is in the wrong forum - the question involves a query and a form.
Brief background - this is some code involving carrying out an action depending on the results of a query to be active on the open event of the main form in the database. The form is not based on a table.
There is a hidden text box on the form which captures the users Windows NT NetID when they open the form.
Inserted into the form is a subform which is based on a query which returns the users information which is stored in a table in the database, and is returned via the stored NetID value on the main form.
What I am trying to do is disable a button if the user's captured NetID does not exist in the table.
What I have tried to use is variations of:
If Me!frmUserinfo!Usernetid Is Null Then
Me!Button1.enabled = False
Else: Me!Button1.enabled = True
End If
The idea behind this is to give everybody access to the database, but only registered users (Entered into a table by admin) will have access to Button1. The idea being that the query determines that the user is not registered because it returns no values (the netid is not found in the table) and so the subform, and specifically the netid field, contains no value.
But I can't get this to work!!
I have tried the following:
If Me!frmUserinfo!Usernetid Is Null Then
Me!Button1.enabled = False
Else: Me!Button1.enabled = True
End If
(this throws an error)
If Me!frmUserinfo!Usernetid = Null Then
Me!Button1.enabled = False
Else: Me!Button1.enabled = True
End If
(this doesn't do anything)
If Me!frmUserinfo!Usernetid = "" Then
Me!Button1.enabled = False
Else: Me!Button1.enabled = True
End If
(this doesn't work)
All help is gratefully appreciated!
Andy.