|
-
Jul 31st, 2006, 10:17 PM
#1
Thread Starter
Addicted Member
Auto date and user name in a textbox
Hi, i have a textbox in my MS Access 97 form where different users can enter comments, however we can't track when and by whom. How can i add the date and the user name automatically everytime when the user click on the textbox and by keeping the previous comments in that textbox. Thanks
-
Aug 1st, 2006, 06:02 AM
#2
Re: Auto date and user name in a textbox
you want to add fields to table to store date and user, or add to textbox text?
in the click event
VB Code:
textbox.text = Now & " " & user & " " & textbox.text
pete
-
Aug 1st, 2006, 06:25 AM
#3
Thread Starter
Addicted Member
Re: Auto date and user name in a textbox
The data from txtComments textbox is stored in my database (Comments) as a note field. So when i load the form, a user can add new comments below the previous comments.
-
Aug 1st, 2006, 07:32 AM
#4
Re: Auto date and user name in a textbox
VB Code:
database(comments) = database(comments) & now & " " & user & vbnewline & txtcomments
should do the trick
pete
-
Aug 1st, 2006, 08:38 PM
#5
Thread Starter
Addicted Member
Re: Auto date and user name in a textbox
thanks its working. how can i make the text permanent that is the user can't erase the date and username.
-
Aug 1st, 2006, 08:42 PM
#6
Re: Auto date and user name in a textbox
use separate textboxs to display and add, don't save changes to the display one
pete
-
Aug 3rd, 2006, 06:44 PM
#7
Member
Re: Auto date and user name in a textbox
use separate textboxs to display and add
txtdisplaytext locked property: Yes
VB code:
txtaddtext_AfterUpdate
txtdisplaytext=txtdisplaytext & now & " " & user & vbnewline & txtaddtext
end sub
then save txtdisplaytext to your database
-
Aug 7th, 2006, 02:11 AM
#8
Thread Starter
Addicted Member
Re: Auto date and user name in a textbox
i'm getting this error -
" You can't reference a property or method for a control unless the control has the focus. I changed the txtAdd.setfocus i'm still getting the same error.
VB Code:
Private Sub txtAdd_AfterUpdate()
txtDisplay.SetFocus
txtDisplay.Text = txtDisplay.Text & vbNewLine & vbNewLine & Now() & " " & vbNewLine & CurrentUser() & vbNewLine & txtAdd.Text
End Sub
-
Aug 7th, 2006, 06:41 AM
#9
Re: Auto date and user name in a textbox
is txt display locked or otherwise disabled?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 8th, 2006, 01:52 AM
#10
Thread Starter
Addicted Member
Re: Auto date and user name in a textbox
the form is set up in a way that all the controls are locked therefore only viewing. If you need to modify then click the user has to click on the 'Edit' button to enable all the controls.
-
Aug 9th, 2006, 08:25 AM
#11
Re: Auto date and user name in a textbox
is the txtdisplay still locked when you try to upate it, or are all the controls unlocked after edit is clicked?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 9th, 2006, 08:28 PM
#12
Thread Starter
Addicted Member
Re: Auto date and user name in a textbox
all the controls are unlocked after the edit button is clicked
-
Aug 9th, 2006, 09:33 PM
#13
Re: Auto date and user name in a textbox
are these textboxs bound to the data?
if so update the table/database the textbox should display
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|