need help with ColumnHistory()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sooli
    New Member
    • Sep 2014
    • 49

    #1

    need help with ColumnHistory()

    Trying to make a "white board" type feature in my database so we can share information between shifts.

    I like the ColumnHistory() feature, but it seems to keep adding to the history even if you don't type anything in.

    I think it has something to do with the Nz() part of the standard code, but am unsure exactly. Everytime the form is opened, it creates a new line and I don't want it to create a line unless the post button is hit...

    History Text box code is:
    Code:
    =ColumnHistory([RecordSource],"Comments","[ID]=" & nz([ID],0))
    form load code is:
    Code:
    Private Sub Form_Load()
    On Error GoTo Form_Load_Err
    
        If (Not IsNull(OpenArgs)) Then
            DoCmd.GoToRecord , "", acLast
        End If
        If (Not CurrentProject.IsTrusted) Then
            Exit Sub
        End If
        Comments.Value = " "
        txtComments.Visible = True
           
        
        TempVars.Add "NewData", Mid(Nz(OpenArgs), InStr(Nz(OpenArgs), "=") + 1)
        On Error Resume Next
        If (TempVars!NewData <> "") Then
            Title = TempVars!NewData
        End If
        TempVars.Remove "NewData"
        
    
    Form_Load_Exit:
        Exit Sub
    I thought the "TempVars.add.. ." might be the cause of this, but when i commented it out, it still happens...how can I make this only store/display data if the Post button is hit?

    Also would like it to not say "Version: 6/19/05..." how do i make the word "version" disappear and only the date and time show up?


    thanks for your help!
    Sophie
  • sooli
    New Member
    • Sep 2014
    • 49

    #2
    oh! seems

    Code:
    Comments.Value = " "
    txtComments.Visible = True
    was the culprit... so that is fixed..

    Comment

    • sooli
      New Member
      • Sep 2014
      • 49

      #3
      is there a way to make it display newest to oldest? so the most recent comment is at the top?

      Comment

      • sooli
        New Member
        • Sep 2014
        • 49

        #4
        i got it to at least load with the cursor at the end of the text, using

        Code:
        txtComments.setfocus
        Me!txtComments.SelStart = Me!txtComments.SelLength
        but I'd really like to have the data appear in reverse order...

        Comment

        • jforbes
          Recognized Expert Top Contributor
          • Aug 2014
          • 1107

          #5
          It looks like the History is being appended to by a piece of code that hasn't been supplied. It's probably in the BeforeUpdate Event of the Form or off a button that saves off the History text. The question is whether or not when the History is saved, is it just appending to a Text field or is it creating a separate record for each piece of history.
          • If it is appending the History, then to get it in reverse order, the History would need to be prepended instead.
          • If there is a record for each piece of history, the ColumnHistory() function could be modified to allow you to supply the sort order... or just hardcoded in reverse order.


          Having a peek at the ColumnHistory() function would probably answer this question.

          Comment

          Working...