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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Username and tbl lookup Problem

Status
Not open for further replies.

robcarr

Programmer
May 15, 2002
633
GB
Hi,

I have a database that is used to log absences, I use the users network login to identify them and display data that is held about them within a specific table (tblusers), the database has started to fail when it opens for a random select group.

the main form is a bound form using this query

Code:
SELECT tblUsers.LoginID, tblUsers.ManagerName, tblUsers.Campaign, tblUsers.EmailAddress, tblAgentListing.OPSManager
FROM tblUsers INNER JOIN tblAgentListing ON tblUsers.ManagerName = tblAgentListing.LineManager
WHERE (((tblUsers.LoginID)=fOSUserName()));

fosusername() function is

Code:
Function fOSUserName() As String

        fOSUserName = UserNameWindows
        MsgBox UserNameWindows
End Function

Function UserNameWindows() As String
   
    Dim lngLen As Long
    Dim strBuffer As String
   
    Const dhcMaxUserName = 255
   
    strBuffer = Space(dhcMaxUserName)
    lngLen = dhcMaxUserName
    If CBool(GetUserName(strBuffer, lngLen)) Then
        UserNameWindows = Left$(strBuffer, lngLen - 1)
    Else
        UserNameWindows = ""
    End If
End Function
the message box finds the username and displays this and then the form shows no data and all controls are gone - probably becauase it is bound and cant find the username - but the msgbox does find the username

the form is bound by the above query - when you run the query separately it doesn't find the data from the function, but you run the function and it does find the data.

the users do exist in the table and everything is correct.

any ideas what maybe cuasing this





Hope this is of use, Rob.[yoda]
 
here is the coding for the form load event

Code:
DoCmd.Maximize
Forms!frmmainpage.Text22 = GetUserName
If Not CommandBars.GetPressedMso("MinimizeRibbon") Then
CommandBars.ExecuteMso "MinimizeRibbon"
End If
DoCmd.ShowToolbar "Ribbon", acToolbarNo
Call SetEnabledState(False)
'Forms!frmmainpage.RecordSource = "qryfinduserdetails"
Dim rst As DAO.Recordset
Dim lngCount As Long
Set dbs = CurrentDb
Set rsq = dbs.QueryDefs("qryLMAbsCount")
rsq.Parameters("l") = Me.ManagerName
On Error GoTo CheckRecordsetExit
Set rst = rsq.OpenRecordset()
With rst
    If rst.EOF Then
        Me.Text15 = 0
        Exit Sub
    End If

    .MoveFirst
    .MoveLast
    lngCount = .RecordCount
End With

Me.Text15 = lngCount
CheckRecordsetExit:
Exit Sub

Hope this is of use, Rob.[yoda]
 
the msgbox does find the username" I would first try to see exactly what am I getting in the message box. You may have spaces before or after user name:

Code:
MsgBox [blue]"*" & [/blue]UserNameWindows[blue] & "*"[/blue]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
it shows no spaces the * are exactly either side of the username on mine and on the user who cant get it load, but it does show his username in between and it still loads blank it cant locate him, and he does exist in the database table


Hope this is of use, Rob.[yoda]
 
Is the application in a trusted location for all users?

If you query on it own doesn't show records then it doesn't have anything to do with the form or your code or anything else. It's just the query and your data. What happens when you change the INNER JOIN to a LEFT JOIN.

Duane
Hook'D on Access
MS Access MVP
 
ill have a check and let you know, the annoying thing is works on 40 pcs but not the others

Hope this is of use, Rob.[yoda]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top