Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a field not visible on one network computer

Status
Not open for further replies.

tarena

IS-IT--Management
Nov 28, 2005
70
0
0
US
I'm using Access 97. I have a form that has a subform that has one field that I need to make not visible to one computer on our network. Is there a way to do this with code or any other way?

Thank you
Tarena
 
It may be possible to use:

Environ("computername")

To check the computer name, however, I am not sure if this will work with your set-up.
 
Yuo can get the computername with:

**Declarations
Private Declare Function apiGetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long


**function
Function txtMachineName() As String
'Returns the computername
Dim lngLen As Long, lngX As Long
Dim strCompName As String
lngLen = 16
strCompName = String$(lngLen, 0)
lngX = apiGetComputerName(strCompName, lngLen)
If lngX <> 0 Then
txtMachineName = Left$(strCompName, lngLen)
Else
txtMachineName = vbNullString
End If
End Function


Then use a simple if in the OnLoad to hide the control:

if txtMachineName="MyMachine" then
mycontrol.visible=false
else
mycontrol.visible=true
end if
 
inquiring minds (always?) want to know ... WHY in the world of your application do you want to hide from ONE computer? couldn't the user just log on elsewhere and see it? What is special about the field value(s) with respect to the specific workstatioon?

ps the above may need tweaking if the control is further manipulated through code or user access to the design mode of the object, of course only a semi-knowledgable user would know how to do the latter, but code is just code - and doesn't care who/what/when/why or how hte code is instantiated ...




MichaelRed


 
You can use a similar function to get/compare a login name.

You could have an 'access level' table that allowed/disallowed certain users to view certain fields or forms.

Jonathan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top