[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

vba code to capture the user's sql login name

Posted on 2011-02-21
10
Medium Priority
?
516 Views
Last Modified: 2013-11-27
I want to be able to capture and display the user's sql login name on my form when the user checks a checkbox called "InvestigationComplete" on my form.  Is there a way to accomplish this programatically.  I have admin writes to Microsoft SQL server.  The datasource is "ucrdata" sql table with a field called TestTech that I want to capture this login name.
Private Sub InvestigationComplete_Click()
Me.InvestigationComplete.Value = -1
Me.InvestigationComplete.Locked = True
Me.TestTech.SetFocus
me.TestTech.Value = ............user's sql login ID............
End Sub

Open in new window

0
Comment
Question by:sxxgupta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 46

Expert Comment

by:aikimark
ID: 34947218
are you not using the Windows login for authentication?
0
 

Author Comment

by:sxxgupta
ID: 34947232
No, our IT group is not using this option as users may have the same generic windows login name (BTW...I am not in IT but in quality engineering)
0
 
LVL 5

Expert Comment

by:roger_karam
ID: 34947617
Hello. From what I've read, user for SQL Server is SYSTEM_USER.
You are however in a MS Access section...
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:sxxgupta
ID: 34947915
yes??
0
 

Author Comment

by:sxxgupta
ID: 34947917
again, how do I use vba code to capture the sql login id of a user?
0
 
LVL 5

Expert Comment

by:roger_karam
ID: 34948125
Sorry, I guess what I meant to say is: where are you applying this code? in a VB accessing a SQL Server from excel?
0
 

Author Comment

by:sxxgupta
ID: 34948159
sorry for not clarifying

vba code accessing a sql server from Microsoft Access (version 2002) form.
0
 
LVL 5

Accepted Solution

by:
roger_karam earned 2000 total points
ID: 34948179
Ah... well, I think that's been done. Try adding the funcion from Jalcadmim (http://www.experts-exchange.com/Microsoft/Development/MS_Access/Access_Coding-Macros/Q_23630570.html)

me.TestTech.Value = GetSqlUser()


Function GetSqlUser() As String
Dim qrd As DAO.QueryDef, rst As DAO.Recordset

Set qrd = CurrentDb.CreateQueryDef("")
With qrd
.Connect = CurrentDb.TableDefs(0).Connect
.SQL = "SELECT SYSTEM_USER"
.ReturnsRecords = True
End With

Set rst = qrd.OpenRecordset()
GetSqlUser = rst(0).Value

rst.Close
Set rst = Nothing
Set qrd = Nothing
End Function
0
 

Author Closing Comment

by:sxxgupta
ID: 34951215
Awesome!!!!!!!!!  Thanks Roger:)
0
 
LVL 5

Expert Comment

by:roger_karam
ID: 34954506
Thanks for the points sxxqupta!

Glad I could help, but credit goes to jalcadmin for the solution!

-RK
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question