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?
**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 ...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.