Function in SQL

thmsjlmnt3953

Registered User.
Local time
Today, 17:01
Joined
May 20, 2014
Messages
120
Hi

i have the following function declared however cant get it to work in the sql string..

Code:
Public Function GetSystemID() As String
GetSystemID = fOSUserName
End Function

however cant get it to return the required value in the SQL string..

Code:
    DoCmd.RunSQL "INSERT INTO tblLogs (LoginUser, LoginTime, SystemUser) " _
                  & "VALUES(forms.frmlogin.txtUserID.Value, Now(),GetSystemID) "

any help would be appreciated?
 
Try . . .
Code:
   CurrentDb,Execute _
      "INSERT INTO tblLogs " & _
         "( LoginUser, LoginTime, SystemUser ) " & _
      "VALUES " & _
         "( forms!frmlogin.txtUserID.Value, Now(), GetSystemID() );", dbFailOnError
 
Hi

i now get undefined function 'getsystemid' in expression?
 
Where is your function declared? It needs to be in a standard module, so not in a class module, and not in a module attached to a form.

If it is on a form that is open, you can qualify the name as you did for 'txtUserID' . . .
Code:
Forms!SomeForm.GetSystemID()
Hope that helps,
 

Users who are viewing this thread

Back
Top Bottom