none
User Activity Log RRS feed

  • Question

  • I need to record what PatientID has been viewed by a user in a log. A log table tblActivityLog is created. It has fields TimeStamp, UserName, PatientID, Activity.

    The following Module ("Globals") is created

    --------------------------

    Public Sub PatientLog(PatientID As String, Activity As String)
        CurrentDb.Execute "INSERT INTO tblActivityLog (UserName, PatientID, Activity) Values('" & TempVars("UserName").Value & "', '" & "PatientID.Value" & "', '" & Activity & "')"
       
    End Sub

    ----------------------------

    On the Patient form I made the following

    ----------------------------

    Private Sub Form_Current()
        Globals.PatientLog "PatinetID", "View Patient File"

    End Sub

    ----------------------------

    Problem: PatinetID is not recorder in tblActivityLog. Could you please advise?

    Friday, January 27, 2017 2:27 PM

Answers

  • Hi Oleg.bv -

    Couple things jump out & I'm sure the minds here will see others:

    1) Your call uses a literal string when I suspect you really want the value of a textbox named PatientID. I don't know if the value "PatientID" conforms to the field requirements (also at issue in #3 below):

    IS: Globals.PatientLog "PatinetID", "View Patient File"

    SB: Globals.PatientLog tbxPatientID.value, "View Patient File"

    2)Spelling: "PatinetID" isn't "PatientID" in the line    Globals.PatientLog "PatinetID", "View Patient File"

    3) You have declared "Public Sub PatientLog(PatientID As String, Activity As String)". PatientID therefore does not have a .Value property. I would also use a different variable name so that I don't get confused. Also - You also have surrounded 'PatientID.Value' in quotes. Therefore you should see PatientID.Value in all of your PatientID rows.
    Is:

    Public Sub PatientLog(PatientID As String, Activity As String)
        CurrentDb.Execute "INSERT INTO tblActivityLog (UserName, PatientID, Activity) Values('" & TempVars("UserName").Value & "', '" & "PatientID.Value" & "', '" & Activity & "')"
       
    End Sub

    SB:

    Public Sub PatientLog(PatientRefID As String, Activity As String)
         CurrentDb.Execute "INSERT INTO tblActivityLog (UserName, PatientID, Activity) Values('" & TempVars("UserName").Value & "', '" & PatientRefID & "', '" & Activity & "')"
         
     End Sub


    -MainSleuth You've Got It, Use It! Engineering, Science, Statistics Solutions http://ToolSleuth.com


    • Edited by MainSleuth Friday, January 27, 2017 2:58 PM
    • Marked as answer by Oleg.bv Friday, January 27, 2017 5:34 PM
    Friday, January 27, 2017 2:56 PM
  • Made all changes you suggested:

    Getting error message: Run-time error '424'. Object required.

    FYI:
    PatientID is a text box (foreign key in the table tblPatientCare which is
    the source of this form and PK on tblPatients). This specific column is not
    visible for a user. PatientName (2nd column) is actually visible - it is a dropdown. I do not know
    if this makes the difference.<o:p></o:p>

    Spelling is corrected.<o:p></o:p>


    • Marked as answer by Oleg.bv Friday, January 27, 2017 5:34 PM
    Friday, January 27, 2017 5:28 PM
  • Changed from "PatientID.Value" to PatientID. Now works. Thank you very much!
    • Marked as answer by Oleg.bv Friday, January 27, 2017 5:34 PM
    Friday, January 27, 2017 5:34 PM

All replies

  • Public Sub PatientLog(PatientID As String, Activity As String)
        CurrentDb.Execute "INSERT INTO tblActivityLog (UserName, PatientID, Activity) Values('" & TempVars("UserName").Value & "', '" & "PatientID.Value" & "', '" & Activity & "')"

    Hi Oleg.bv,

    What happens if you change    "PatientID.Value"    to    PatientID    ?

    With the quoted string the literal value of rhe string is taken, whereas without the quotes the value of the variable is taken, jyust as is the case with  Activity.

    Imb.

    Friday, January 27, 2017 2:52 PM
  • Hi Oleg.bv -

    Couple things jump out & I'm sure the minds here will see others:

    1) Your call uses a literal string when I suspect you really want the value of a textbox named PatientID. I don't know if the value "PatientID" conforms to the field requirements (also at issue in #3 below):

    IS: Globals.PatientLog "PatinetID", "View Patient File"

    SB: Globals.PatientLog tbxPatientID.value, "View Patient File"

    2)Spelling: "PatinetID" isn't "PatientID" in the line    Globals.PatientLog "PatinetID", "View Patient File"

    3) You have declared "Public Sub PatientLog(PatientID As String, Activity As String)". PatientID therefore does not have a .Value property. I would also use a different variable name so that I don't get confused. Also - You also have surrounded 'PatientID.Value' in quotes. Therefore you should see PatientID.Value in all of your PatientID rows.
    Is:

    Public Sub PatientLog(PatientID As String, Activity As String)
        CurrentDb.Execute "INSERT INTO tblActivityLog (UserName, PatientID, Activity) Values('" & TempVars("UserName").Value & "', '" & "PatientID.Value" & "', '" & Activity & "')"
       
    End Sub

    SB:

    Public Sub PatientLog(PatientRefID As String, Activity As String)
         CurrentDb.Execute "INSERT INTO tblActivityLog (UserName, PatientID, Activity) Values('" & TempVars("UserName").Value & "', '" & PatientRefID & "', '" & Activity & "')"
         
     End Sub


    -MainSleuth You've Got It, Use It! Engineering, Science, Statistics Solutions http://ToolSleuth.com


    • Edited by MainSleuth Friday, January 27, 2017 2:58 PM
    • Marked as answer by Oleg.bv Friday, January 27, 2017 5:34 PM
    Friday, January 27, 2017 2:56 PM
  • Made all changes you suggested:

    Getting error message: Run-time error '424'. Object required.

    FYI:
    PatientID is a text box (foreign key in the table tblPatientCare which is
    the source of this form and PK on tblPatients). This specific column is not
    visible for a user. PatientName (2nd column) is actually visible - it is a dropdown. I do not know
    if this makes the difference.<o:p></o:p>

    Spelling is corrected.<o:p></o:p>


    • Marked as answer by Oleg.bv Friday, January 27, 2017 5:34 PM
    Friday, January 27, 2017 5:28 PM
  • Changed from "PatientID.Value" to PatientID. Now works. Thank you very much!
    • Marked as answer by Oleg.bv Friday, January 27, 2017 5:34 PM
    Friday, January 27, 2017 5:34 PM
  • Cool - glad you have worked out the solution

    -MainSleuth You've Got It, Use It! Engineering, Science, Statistics Solutions http://ToolSleuth.com

    Friday, January 27, 2017 7:43 PM