Ask Experts Questions for FREE Help !
Ask
    ACC2012's Avatar
    ACC2012 Posts: 7, Reputation: 1
    New Member
     
    #1

    Nov 26, 2014, 03:22 PM
    Track use in access 2010
    I've created a database that supervisors, managers, directors, and senior administration can use to log employee "Performance Events." Like praise or coaching. We have many sites and employees often "float" under different management. For this reason, all management can view all events. We want to leave it this way BUT I need to build a tracking system that monitors who's viewed what record. I've found the Allen Brown solution of LogDocOpen/LogDocClose which works great but only logs the name of the report and/or form. I need to log the specific record viewed. I can't seem to find a solution. Does anyone have suggestions?
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #2

    Nov 26, 2014, 05:19 PM
    Not hard to do but the question is how does a user select a record? That has to be controlled to be able to do this.
    ACC2012's Avatar
    ACC2012 Posts: 7, Reputation: 1
    New Member
     
    #3

    Dec 19, 2014, 03:46 PM
    They would open a form and select an employee name from a combo box. I want to record which employee is chosen from the combo box.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #4

    Dec 22, 2014, 05:30 AM
    Ok, do you want to continue to use Allen's utility? Or do you just want to record which employee was looked at, by whom and when?

    If the latter you can use code like this in the After Update event of your selection combo:

    Dim strSQL

    strSQL = "INSERT INTO tblLog (EmployeeID, ManagerID, ReviewedWhen) " & _
    "VALUES(" & Me.cboEmployee & ", '" & NetworkUserName() & "', #" & Now() &#);"
    CurrentDB.Execute strSQL, dbFailOnError

    You need to create a table like so:

    tblLog
    LogID (PK Autonumber)
    EmployeeID
    ManagerID
    ReviewedWhen (DateTime)

    The datatypes of EmployeeID and ManagerID will depend on how you have your db setup. I'm assuming that ManagerID will use the NetworkUserName() function in Allen's code. You need to use the actual name for the combo that you select the employee from.
    ACC2012's Avatar
    ACC2012 Posts: 7, Reputation: 1
    New Member
     
    #5

    Dec 22, 2014, 08:21 AM
    Ok, I think I'm very close but I'm getting an error when I compile "Compile error: Sub or Function not defined." It highlights the name of the combo box in the code, specifically, the ".Employee" (my combo box name) portion. Is this because the combo box is unbound? I didn't bind this as this form is only used to run reports based on the performance event table. Below is the code I entered:

    Private Sub Employee_AfterUpdate()

    Dim strSQL

    strSQL = "INSERT INTO tblLog (EmployeeID, ManagerID, ReviewedWhen) " & _ "VALUES(" & Me.Employee & ", '" & fOUserName() & "', #" & Now() & "#);" CurrentDb.Execute strSQL, dbFailOnError

    End Sub

    I appreciate all of your help!
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #6

    Dec 22, 2014, 08:38 AM
    First, the _ is a continuation character. It indicates that the code continues on the next line. I don't know whether what you copied and pasted is representative or not, but it needs to look like this:

    strSQL = "INSERT INTO tblLog (EmployeeID, ManagerID, ReviewedWhen) " & _
    "VALUES(" & Me.Employee & ", '" & fOUserName() & "', #" & Now() & "#);"
    CurrentDb.Execute strSQL, dbFailOnError

    Second, are you sure Employee is the name of the control? You can find the name by selectign the control in Design mode then looking at the Other Tab of Property Dialog.
    ACC2012's Avatar
    ACC2012 Posts: 7, Reputation: 1
    New Member
     
    #7

    Dec 22, 2014, 09:20 AM
    Ok, yes, I have the _ because "VALUES starts on the next line.

    Yes, design view property sheet on the combobox on other tab, name says Employee.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #8

    Dec 22, 2014, 09:26 AM
    Hmm, then it should work. Can you attach a stripped down and zipped version to a response here?
    ACC2012's Avatar
    ACC2012 Posts: 7, Reputation: 1
    New Member
     
    #9

    Dec 22, 2014, 03:30 PM
    I found that error. I needed "fOSUserName" not "fOUserName". (Ugh!) But now I'm getting a different error that says "Number of query values and destination fields are not the same." I'm thinking that this may be because my "Employee" combobox combines 3columns, employee name, ID, & Position. I did this so that when the name is chosen, below it automatically populates a text box with the ID using =[Employee].[Column](1). Same for the position. I tried changing the INSERT INTO code to Me.Employee.Column(0) but this obviously didn't work. Do I need to set some sort of parameters with VALUES?
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #10

    Dec 23, 2014, 05:36 AM
    No, it has nothing to do with that. The error means that the number of fields in your Fields clause (the list of fields on the first line) doesn't match the number or type of values in the Values clause. Since it does appear to be 3 of each. Then you need to look at the datatypes. What datatype is the EmployeeID field? Since that seems most suspect.
    ACC2012's Avatar
    ACC2012 Posts: 7, Reputation: 1
    New Member
     
    #11

    Dec 23, 2014, 07:51 AM
    The datatype in the tblLog for EmployeeID is Text.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #12

    Dec 23, 2014, 07:53 AM
    That's what I figured. Ok change the code to:

    strSQL = "INSERT INTO tblLog (EmployeeID, ManagerID, ReviewedWhen) " & _
    "VALUES('" & Me.Employee & "', '" & fOUserName() & "', #" & Now() & "#);"
    CurrentDb.Execute strSQL, dbFailOnError

    Since it's a text datatype, you have to put the single quotes around it, the same as I did for ManagerID.
    ACC2012's Avatar
    ACC2012 Posts: 7, Reputation: 1
    New Member
     
    #13

    Dec 23, 2014, 08:03 AM
    I got it to work! I thought about what you said about the Employee ID field and you were right about the datatype. I needed to add ' to the beginning and end of " & Me.Employee & ". Below is the code that works. :) Thank you so much for all of your help!

    Dim strSQL As String
    strSQL = "INSERT INTO tblLog (EmployeeID, ManagerID, ReviewedWhen) " & _
    "VALUES('"VALUES('"', '" & fOSUserName() & "', '" & Now() & "', #"
    CurrentDb.Execute strSQL, dbFailOnError

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Access 2010 - Security and Login [ 9 Answers ]

Hi, I need your help! I have a good knowledge on Excel and VBA but I'm a newbie on Access. I'm currently working on a database on Access 2010 where there should be 4 types of users (Admin, Approvers, Inputters, Readers). I've followed the instructions to create a login that worked perfectly...

Microsoft Access 2010 IIF Function [ 18 Answers ]

The Subtotal field in my Expenses tbl contains the following expression: IIf(="Tuition/Fees" Or "Airfare" Or "Taxi" Or "Ground Transportation" Or "Registration Fee" Or "Miscellaneous" Or "Salary for the period",,(*)) However, it is not producing the result I need. The result from the...

MS Access DB 2010 [ 1 Answers ]

I created a simple access db, with 1 table and 3 columns. Table Name: Machining_Fixtures Column 1 Name: ID Column 2 Name: Location Column 3 Name: Fixture There are 500 records in this table. I just want to be able to enter the location and have it bring me back the fixture, or enter the...

Issues creating a one to many relationtionship in Access 2010 [ 9 Answers ]

I have two tables (Clients / Quotes) and I want to create a report for each client displaying a list of quotes that has been sent to them. The 'Quotes Form' can have up to 6 clients being priced the same project with a 7th client field for the winning client. So the relationship view looks like...

Need help creating a relationship in Access 2010 [ 4 Answers ]

Hi all, I'm trying to build an access db (I don't know access very well) to keep track of my rechargeable batteries (geeky I know). Here are my tables: BatteryType: Just contains the different types of batteries available Inventory: contains batterytype, serial number, purchase date, etc...


View more questions Search