General :: How To Write Sample Code To Retrieve Current User Name
Sep 25, 2013
How to write Sample Code to Retrieve the Current User Name?I have done for short name only and I need it full
Private Declare Function apiGetUserNameWindows Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
Dim lngLen As Long, lngX As Long
Dim strUserName As String
I have form "frmOrders" (Datasheet), columns: "id_order", "nameOfOrder", "worker", "term", "changes"I don't know it's possible or not.
e.g. I have in some record values like this Id_order - 2 NameOfOrder - folder Worker - John term (this field is empty)
some day I will change e.g. nameOfOrder from "folder" to "business card" and term from empty to 2013-07-13. So two records was changed. After changes, record "changes" should has value like this "folder; term" - because I changed these columns.
I'm a SQL Server DBA and have a few Access 2010 Db's to look after and occasionally have to make amendments to (as is the case today). I've been asked to apply permissions to certain users of the Access database whereby users in a group we're calling 'Viewer' only have read permission and users in another group called 'Writer' (original I know!) have both read and write permission.
The database is form driven (i.e. no-one directly accesses and amends the tables in the database), the file is saved with a .mdb extension.
I've played around with the 'Manage Users & Permissions' in the File Menu however these don't seem to do what I need them to and only result in having to input a user and password to access the database on start-up.
Does a (the) .ldb file have to be closed for another user on a network (separate FE linked to network drive BE) to read/write info to a table? Or even select info from a table?
how i can get a current user from a custom login form CurrentUser() this function always return a system user name admin as default. In my login schema i have a Hidden splash form that have a unbound field that holds user name from custom login form after login a dashboard execute and also display user name on dashboard according to user login ,this working fine for mine. Actually i want to make a currentuser stamp in every entry when a record is entered in database.
I have an access program and i want it to save a copy into a location... ive got it so it can save however - i want it to save to the current users documents folder (win 7)
I have a small problem: I just want my form to update the current record because I'm opening (with a button) a second form which uses the values of some of its table fields. If I open 2nd form without updating, it will use old values, and if the record I was worknig with is a NEW record, 2nd form simply can't find it because it's not been written! So: 1. I want to tell the button to UPDATE record before opening the 2nd form. 2. In addition, I could want to go to 2nd form DIRECTLY from the same field I want to update and use in 2nd form (through a Keypress event instead of a button), but this is more difficuolt because I still didn't EXIT from the field but I already want to use the text manually updated in the field... any idea?
I have a report rptEnvelopes to print envelopes. In the report I have text box called txtRecipientName . I have a qryAddress with fields notNo, IDCard, Fname, Lname where notNo is a field that takes its value from a combo box called cboSelectEnvelope from a form frmPrinting. I then wrote the following code:
Private Sub Report_Open(Cancel As Integer)
Dim dbLet As Database Dim rsLet As Recordset Dim sqlLet, criteriaLet, txtRecipientName As String Dim stLet as String
Set dbLet = CurrentDb sqlLet = " Select DISTINCT IDCard FROM qryAddress " & _ "WHERE notNo = " & Forms!frmPrinting!cboSelectEnvelope Set rsLet = dbLet.OpenRecordset(sqlLet, dbOpenSnapshot) If Not rsLet.EOF Then rsLet.MoveLast stLet = "rptEnvelope" criteriaLet = "notNo=" & Forms!frmPrinting!cboSelectEnvelopeReports 'This is where I go wrong: 'How to I declare txtRecipientName, on rptEnvelope, to get the value rsLet!Fname&" "& rsLet!Lname DoCmd.OpenReport stLet, acViewPreview, , criteriaLet End If rsLet.CLOSE
NOTE: Private Sub Report_Open is called from the On Open Event of rptEnvelope
What I really need is for when the form opens, it looks at todays date, then matches current user and then goes to that record for today, if no current user there, then will goto new record..
i know, sounds complicated, and probably is really easy, but my heads not with it today, as about to get drunk as its my 40th, and got people ringing and texting and still trying to get this done....
I've included a copy of this database, named Timecards..
all using access 2010. I have a date field. I need to write a query to pull out dates with current year only. ex data: 1/1/10, 1/1/11, 2/1/12, 2/1/13. Need to pull all dates with current year which would be 2/1/13. Tried in query criteria of the date field: =Format(Now(),"yyyy") I received data mismatch. this is a date/time field.
On the OnLoad event of a form, is it possible for the program to traverse or go through every single record (maybe with a while loop)?? If so, please send me the exact syntax.
Also, I want to update the tables on the back end. Is it possible to this in the be file? Where specifically would I have to put the code?
Here is my problem. I have several fields located on a form. The user has a problem finding the curser on what field its on. I did ok with the text fields, but I need to come up with something for the check boxes. Any Ideas
The code below works good for text fields. But I need to do the same for Check Boxes or the Check Box Label that is associated with the check Box.
Private Sub Ctl4bCode_Enter() Me.Ctl4bCode.BackColor = RGB(255, 0, 0)
End Sub
Private Sub Ctl4bCode_Exit(Cancel As Integer) Me.Ctl4bCode.BackColor = RGB(255, 255, 255)
I'm not an advanced user of Microsoft Access 2010, I've been working on a database for a company that does Non Destructive Testing, so my task is to simplify how the technicians process the information and make their jobs easier.
Firstly, I have assigned a Unique Identification to a code in this case - X8120 This code is assigned to a row of information.
What i want to do is enter the code X8120 into a text-box and once the code is enter, i want the database to retrieve all information that's assigned to that code from the row (which is 17 fields) in a table.
When the information is retrieve, i want those 17 fields to automatically populate into their own text-boxes, so there would be 17. This would all be on one form. So the technician only has to enter a code which displays the information relating to the testing the technicians have done.
What i have done so far is made the table into a form and added a select button command, so a technician would click on a button that opens a form and select the row of information they want and populates those 17 fields.
So my aim is to simply enter a code or an event and the database will retrieve the information instead of going through a form to select the information. So i am simplifying the process even more.
Well I know why this happens b/c the table that the information is being pulled is the subsequently being updated however when moving to a diff customer or closing the form etc.. The user is then displayed the MsgBox of Write Conflict and supplying the user with 3 options of Disregarding Changes, Saving changes to Clipboard or Save Changes.
Baisically is their a way to restrict this write conflict msgbox and have it so that it saves the users changes every time.
I wanted to send a message to the person who created this sample database with a modification query but I don't have enough posts to do this, so my message would not send.
The below sample database called Sample - Use Hidden Form to Log Users ,URL...
I would like to add to my database. Any way to modify the form/code so that I can log more than one form? I have 5 forms that I would like to log user in and out of but I dont know how to adapt this to do that?
Will like to check, i have a access database which can be open up by a few users.
How can i only allow the first user who open up the database to read and write the database and the follow users who open up the access have only read access?
i have a subform within a form that i want to create and automated procedure. the subform has a couple of combo boxes.
upon input into the subform i want to do something like if the value of combobox1 starts out with the letter B then the value of combobox3 equals combobox2 * 1/2 i am just having a hard time putting it in code.
as of now i have a on current event on the subform that reads
if me.[combobox1] like "b*" then me.[combobox3] = me.[combobox2]*.05 end if
i have a subform within a form that i want to create and automated procedure. the subform has a couple of combo boxes.
upon input into the subform i want to do something like if the value of combobox1 starts out with the letter B then the value of combobox3 equals combobox2 * 1/2 i am just having a hard time putting it in code.
as of now i have a on current event on the subform that reads
if me.[combobox1] like "b*" then me.[combobox3] = me.[combobox2]*.05 end if
i have a subform within a form that i want to create and automated procedure. the subform has a couple of combo boxes.
upon input into the subform i want to do something like if the value of combobox1 starts out with the letter B then the value of combobox3 equals combobox2 * 1/2 i am just having a hard time putting it in code.
as of now i have a on current event on the subform that reads
if me.[combobox1] like "b*" then me.[combobox3] = me.[combobox2]*.05 end if
I have a problem with write conflict error. The database is functioning normally and without any problems but on particular computer. the systems are same (windows 7) with office 2010.I have a form with subform based on query. Changing the records in a subform is without any problems, but on one particular computar, I am allways receiving Write conflict error message. When I copy / paste the database from the wrong computer to another one, everything is OK. When I copy / paste it back to problematic computer, the problem is back also.It seems, that the problem is maybe somewhere in settings of this computer.
I'm creating a database for a college assignment, and for this database, I need to record the current user ID when a record is created/updated. But I dont know the function (like, Now() returns the current date/time) that gives me the user ID. The help files are awful and I cant find the function I need =(