Controls

Neo

Registered User.
Local time
Today, 19:16
Joined
Mar 5, 2003
Messages
42
I am setting up security in my DB. i am using CASE to determine different option based on the users level.

I need to know how to ref buttons and fields in a form

eg
I though it would be something like

Dim filter as String
filter = Command26.visible = False
DoCmd.openForm "Employee",, filter

Any help would be great thanks
 
Try explaining a little better what you are trying to accomplish. This doens't really make much sense to me.
 
I have a form which asks the user to enter a user ID and Password.

This form then performs a Dlookup and then opens a the form "Master"

The form "Master" Is set up with CASES

Case Admin

Case User

On CASE Amin
Complete access is given

On CASE User
Not all forms open
and on the forms that do I want to make some of the button not visable

eg.

CASE User
Open form "Employees"
button 1.visible = False
 
Filters don't work that way. You don't want to reference the control in the filter. You want the value from the control.

Filters have to be strings similar to an SQL WHERE clause without the word WHERE. Your filter creation would look like

stFilter = "[myChosenField] = True" (for Boolean)

stFilter = "[myChosenField] = 1" (for numbers)

stFilter = "[myChosenField] = ""Value""" (for constant text)

stFilter = "[myChosenField] = """ & CStr([myControl]) & """" (for non-constant text)

stFilter = "[myChosenField] = " & CStr([myControl]) (for non-constant numbers)

where [myChosenField] is a field that is part of the recordsource of the thing you are filtering (not necessarily appearing under that name in the form with the given control on which you base the filter), and [myControl] is the control on the form that provides the filter value for the form or report you want to open. Depending on what is entered to that control, you might wish (for text) to make it Trim$([myControl])

And you might also wish to test Len(Nz([myControl],"")) which, if it is zero, means you have an empty control. I.e. no filtration has been defined.

I didn't look at it closely, but your syntax for actually opening the form with a filter looks OK. It is how you formed the filter string in the first place that was wrong.
 
on the form it is the button I am trying to hide
 

Users who are viewing this thread

Back
Top Bottom