Public Members of Object Models??

JordanR

Registered User.
Local time
Today, 12:10
Joined
Jan 25, 2005
Messages
72
I've been using the same code in my database for probably 8-10 months. Today I get an error. Any idea on where to even begin troubleshooting?

Here's the code:
General - Declarations
Public Declare Function apiGetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function fOSUserName() As String
Dim LngLen As Long, IngX As Long
Dim struserName As String
struserName = String$(254, 0)
IngLen = 255
IngX = apiGetUserName(struserName, IngLen)
If (IngX > 0) Then
fOSUserName = Left$(struserName, IngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function

Private Sub Notes_Dirty(Cancel As Integer)
Enteredby.Value = fOSUserName
Date.Value = Now()

End Sub

Seems super simple, right?
Now out of the blue when someone enters text in the Notes field I get "The expression On Dirty you entered as the event property setting produced the following error: Constants, fixed-length strings, arrays, user-defined types and Declare statements not allowed as Public members of object models."

Please help. Thanks.
 
Last edited:
In a form module an Api must be declared as Private. Also, in the fOSusername function, a variable called LngLen is declared but another variable called IngLen is used, though not declared -- I presume this is a typo. Lastly, it looks like you are using Date as a field or control name.

Regards,
Tim
 

Users who are viewing this thread

Back
Top Bottom