Adding Text to textbox programmatically (Access 97)

gregoryagu

Registered User.
Local time
Today, 04:46
Joined
May 7, 2009
Messages
29
I have a screen that has one large textbox on it. The user goes to this textbox and adds information to the bottom. The text can get very long, several thousand characters or more. (I know it's poorly designed, but I can't change that at the moment.)

I would like to add some code so that the user can press Ctrl + D to add the current date the the bottom of the textbox (or at the cursor would be OK too). To do this, I added the following code:

Private Sub HISTORY_SCREEN_KeyUp(KeyCode As Integer, Shift As Integer)
If Me.ActiveControl = Me.HISTORY_SCREEN Then
If Shift = 2 And KeyCode = 68 Then
Me.HISTORY_SCREEN.text = Me.HISTORY_SCREEN.text + "Insert Date Here"
Me.HISTORY_SCREEN.SelStart = Len(Me.HISTORY_SCREEN.text)
End If
End If
End Sub

However, there are two issue. First, I don't know the code to return the current date in a string format. Second, the code fails because the text is too long to fit in a string variable and so fails.

Any help would be appreciated.

Greg
 
Code:
MyString = Date()
 
or Mystring = FormatDate(..... read the help file for all kinds of available formats, Date())
This will get you the date in any format you choose. I'm not sure about the string not being long enough - I've never ran out of room with a string.

If this is the case, perhaps use 2 strings.

Code:
str1 = Left(TextBox,1,1000)
str2 = Mid(TextBox,1001,len(TextBox))

Evan
 

Users who are viewing this thread

Back
Top Bottom