Error 3075

Snowflake68

Registered User.
Local time
Today, 04:42
Joined
May 28, 2014
Messages
464
I have the function below that obtains the windows username and appends it to an SQL table via an MS Access append query along with information about the job created. This has been working for a few years now without any issues. However the application has been moved to a new database server but it is now producing a runtime error '3075' "Ambiguous name, in query expression 'fOSUserName('.

As you can see from the code below it was originally writtern by Dev Ashish and I have no idea how this works but it does (well used to anyway)

Code:
Option Compare Database
'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
    strUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(strUserName, lngLen)
    If (lngX > 0) Then
        fOSUserName = Left$(strUserName, lngLen - 1)
    Else
        fOSUserName = vbNullString
    End If
End Function
'******************** Code End **************************

This is the SQL for the append query but not sure if it helps or not.
Code:
INSERT INTO dbo_lt_pJournal ( JobNumber, Operator, StockCode, JobStart, WorkType, Complete, CreatedBy )
SELECT Format(Date(),"yymmdd") & [Next Job ID] AS JobNumber, dbo_lt_pOperator.Clock_Number, dbo_InvMaster.StockCode, Now() AS [Time], dbo_lt_pWorkType.Type_No, "N" AS Complete, fOSUserName() AS UserName
FROM dbo_lt_pOperator, dbo_InvMaster, dbo_lt_pWorkType, pGetJobNumber
WHERE (((dbo_lt_pOperator.Clock_Number)=[Forms]![Menu]![pfrmNavSubform]![txtOperator]) AND ((dbo_InvMaster.StockCode)=[Forms]![Menu]![pfrmNavSubform]![txtStockCode]) AND ((dbo_lt_pWorkType.Type_No)=[Forms]![Menu]![pfrmNavSubform]![WorkTypeCombo]![cboWorkType]));

Access version on the server is MS Office Pro 2016

I don't really know anything about the new server as this is not really in my skill set but I maybe able to ask questions about it but I just don't know what to ask.

I hope someone can help me as I am up against time to get this working again.
 
Function is in code more than once?

Search for the function name
 
Function is in code more than once?

Search for the function name

Thanks, that was it. God knows why it was working before but I have removed the duplicate code and all working now. Although different error but I can sort that one.
 

Users who are viewing this thread

Back
Top Bottom