Keep and add to default value in Memo box

Toolpusher

Registered User.
Local time
Today, 02:13
Joined
May 29, 2007
Messages
53
Hi I dont expect this is good DB practice but even though i have a form with a memo box on it. When a new record is created a default valve is inserted in the memo box. i just want to add to the default valve not replace it. So if the default value is abcde I dont want to replace this just add to it abcdefgh. But as soon as i press a key in the memo box abcde is replaced by what I am typing

Any help please
 
From your description the problem is that in the Access Options, at least on the machine you’re testing this on, the Behavior Entering Field is set to Select Entire Field. You could make all users change this to something else, but users have the right to have their Options set the way they prefer, so you need to handle this for situation for this particular Control on this particular app.

SelLength and SelStart both take an Integer as an argument (which is limited to 32,767) but a Memo Field can hold twice that many characters (actually 4 times that, I understand, if the data is entered via code) so you have to be careful using them with Memo Fields! If the data runs to more than 32,767 characters you'll pop an error. So you need to check its length and if Len(MemoFieldTextboxName) > 32767 set it to 32767, which would at least get you a whole lot closer to the end of the data, and hopefully will get you past your Default data.
Code:
Private Sub MemoFieldTextboxName_Click()

If Nz(Me.MemoFieldTextboxName, "") <> "" Then

 If Len(MemoFieldTextboxName) > 32767 Then
  MemoFieldTextboxName.SelStart = 32767
 Else
  MemoFieldTextboxName.SelStart = Len(MemoFieldTextboxName)
 End If

End If

End Sub

You'll need the same code in the MemoFieldTextboxName_GotFocus event, as well. Common sense would dictate that this alone should work when clicking into the Control, but experience proves otherwise, at times. Never have figured out why.

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom