X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Getting Textbox Value Ro Text File, Access 2013    
post Feb 27 2018, 10:00 PM

Posts: 2
Joined: 11-January 18

Pretty sure this is in the wrong spot and has been answered 200 times before, but I simply cannot get this to work properly

My problem is that I have logfile module that works beautifully when users log in or out, but not when I m trying to log user activity to a logfile.

My logging module:

Option Compare Database
Option Explicit
Private FSO As New FileSystemObject

Public Sub WriteLog(message As String)

    Dim filename As String
    Dim txtstream As TextStream
    filename = CurrentProject.Path & "\Logfile_" & Year(Date) & Month(Date) & Day(Date) & ".txt"
    Set txtstream = FSO.OpenTextFIle(filename, ForAppending, True, TristateUseDefault)
    message = Now() & ": " & TempVars("UserName").Value & "-" & message
    txtstream.WriteLine message
    Set txtstream = Nothing
    End Sub

However, when logging user changes in the onclick event, only the function name is being written to the logfile and not the value:

Option Compare Database
Option Explicit

Private Sub btnSaveArtist_Click()

    If Me.Dirty Then
        Me.Dirty = False
    End If
    Globals.WriteLog "new artist added & me.txtartist.value"

End Sub

Logfile line:

28/02/2018 12:25:43 PM: jazza-Logon
28/02/2018 12:26:30 PM: jazza-new artist added & me.txtartist.value

I have tried 400 different ways of writing the function for the onclick event of the form, but every time it comes out as above with the the changes reflected as normal text.

My question is 'What am I missing?'
Go to the top of the page
post Feb 27 2018, 10:13 PM

UA Admin
Posts: 32,108
Joined: 20-June 02
From: Newcastle, WA

Welcome to UtterAccess.

You want to send the text string ""new artist added" to the file, followed by the VALUE of a variable, not the TEXT of the variable.

That means you have use the text delimiters ONLY around the text string, but not around the variable.

Globals.WriteLog "new artist added " & me.txtartist.Value

I am assuming here that the control on the form actually contains the value you want to spend to the log file record.
This post has been edited by GroverParkGeorge: Feb 27 2018, 10:20 PM

Go to the top of the page
post Feb 27 2018, 10:28 PM

Posts: 2
Joined: 11-January 18

Have yourself a cold beer on me, my friend, thank you.

Go to the top of the page

Custom Search
RSSSearch   Top   Lo-Fi    20th March 2018 - 10:37 AM