User, Date and Time stamp to textbox

Steven.Ashby82

Registered User.
Local time
Today, 02:38
Joined
Jan 14, 2013
Messages
63
I'm really sorry if this has already been discussed but I can't find the whole answer.

I currently have some code in my db form where I can create time/date stamped comments (I found the code else where)

Private Sub IndirectDataInput_Click()
If IndirectDataInput.Caption = "Click to Add New Comment" Then
TempDataBox.Visible = True
TempDataBox.SetFocus
IndirectDataInput.Caption = "Submit Comment"
Else
IndirectDataInput.Caption = "Add New Comment"
If IsNull(Me.CommentsField) Then
If Len(Me.TempDataBox) > 0 Then
Me.CommentsField = Now() & " " & Me.TempDataBox
Me.TempDataBox = ""
TempDataBox.Visible = True
Else
TempDataBox.Visible = True
End If
Else
If Len(Me.TempDataBox) > 0 Then
Me.CommentsField = Me.CommentsField & vbNewLine & Now() & " " & Me.TempDataBox
Me.TempDataBox = ""
TempDataBox.Visible = True
Else
TempDataBox.Visible = True
End If
End If
End If
End Sub


I'm trying to find out if I can also add a dropdown list (cbo) to stamp a user to the other details as well.

Thank you in advance
 
I'm trying to find out if I can also add a dropdown list (cbo) to stamp a user to the other details as well.
Hello Steven, I am not sure if I understand this statement properly.. Could you give another shot at explaining??

Also on a side note, in future, please make use of the CODE tags to make the code more presentable and readable..
Code:
Private Sub IndirectDataInput_Click()
    If IndirectDataInput.Caption = "Click to Add New Comment" Then
        TempDataBox.Visible = True
        TempDataBox.SetFocus
        IndirectDataInput.Caption = "Submit Comment"
    Else
        IndirectDataInput.Caption = "Add New Comment"
        If IsNull(Me.CommentsField) Then
            If Len(Me.TempDataBox) > 0 Then
                Me.CommentsField = Now() & " " & Me.TempDataBox
                Me.TempDataBox = ""
                TempDataBox.Visible = True
            Else
                TempDataBox.Visible = True
            End If
        Else
            If Len(Me.TempDataBox) > 0 Then
                Me.CommentsField = Me.CommentsField & vbNewLine & Now() & " " & Me.TempDataBox
                Me.TempDataBox = ""
                TempDataBox.Visible = True
            Else
                TempDataBox.Visible = True
            End If
        End If
    End If
End Sub
 
Sorry,

Currently I type into a unbound text box which i then click submit on which will then add that comment into the comments cell along with a date and time stamp. I can then repeat that process again to create a new time/date and the text will flow into the comment field.

What I would like to do is to also create a drop down list that contains a list of staff names which when I select one of those names will add a stamp of that value along with the date/time which is already specified, at the start of the comment field.

So at the moment I get "12:00 15/01/13 Blah Blah Blah"
I want "Joe Bloggs 12:00 15/01/13 Blah Blah Blah"

Thanks
 
Okay that is not a problem at all.. What you need to do is.. first create that unbound combo box, which will gather all staff names, then in your function..
Code:
Private Sub IndirectDataInput_Click()
[COLOR=Red]    If Me.[COLOR=Blue]staffNamesCombo[/COLOR].ListIndex = -1 Then
        Call MsgBox("You need to select a Staff member", vbInformation)
        Exit Sub
    End If[/COLOR]
    
    If IndirectDataInput.Caption = "Click to Add New Comment" Then
        TempDataBox.Visible = True
        TempDataBox.SetFocus
        IndirectDataInput.Caption = "Submit Comment"
    Else
        IndirectDataInput.Caption = "Add New Comment"
        If IsNull(Me.CommentsField) Then
            If Len(Me.TempDataBox) > 0 Then
                Me.CommentsField = Me.[COLOR=Blue]staffNamesCombo[/COLOR] & " Bloggs " & Now() & " " & Me.TempDataBox
                Me.TempDataBox = ""
                TempDataBox.Visible = True
            Else
                TempDataBox.Visible = True
            End If
        Else
            If Len(Me.TempDataBox) > 0 Then
                Me.CommentsField = Me.CommentsField & vbNewLine & Me.[COLOR=Blue]staffNamesCombo[/COLOR] & " Bloggs " & Now() & " " & Me.TempDataBox
                Me.TempDataBox = ""
                TempDataBox.Visible = True
            Else
                TempDataBox.Visible = True
            End If
        End If
    End If
End Sub
If you have seen I would have added a small Checking condition to see if the user has selected a Staff name, if not they will not be able to add any comments.. Please change the blue bits to match your combo box names.. Hope this helps..
 
You are welcome.. Glad to help.. :)

BTW.. Have you looked into your other thread ? Regarding Images and ComboBoxes? Was that something you were looking for?
 
Just a quick question, Is it possible for the last entry to appear at the top of the comment field? It would be easier for tracking purposes.
 
Well it depends, I had a similar requirement, so what I did was create two separate text boxes (looked like a text area) both unbound, and in one I used to add information, like yours based on a button click. The other one in which will hold the data from the memo field in chronological order.. This might be a bit tricky, as I used the Form Current method to Split the Memo(Comments/Notes in the table) field data, and use Sort to achieve this..
 
Hmmm seems a bit confusing for me lol, how about this!.... Could I create another field that isn't displayed on the form but stored in the table that will only hold the information from the last time the "submit" button was pressed? (I would want to keep all the rest of the code above though)
 
The problem is that this changes to the Table design are (in my view) unnecessary.. The reason I say is that; today you decide to add a field in the table for this reason, then tomorrow you will add another for another reason.. Which makes it a bit more messy.. With displaying data in the Unbound Boxes might be more easier in my opinion.. Just a sample of what I am babbling about..

It does involve a bit of going crazy on the coding.. But at the end of the day it is your call for design changes.. Other people also would have suggestions, so please be patient.. If not start a new thread..
 

Attachments

Users who are viewing this thread

Back
Top Bottom