Memo Field-Cursor moves to first line when entering text

Ray Stantz

Registered User.
Local time
Today, 09:26
Joined
Nov 16, 2006
Messages
63
Hi all,

I have an issue that really has me puzzled. In short, i have a memo field where the cursor automatically moves back to the start of the field everytime i start typing additional text into the field. I changed the cursor behavior to automatically move it to the end of the field by going to Tools/Options/Keyboard/Behavior Entering Field, thinking that would help but i still have the same issue.

Some Background: I have a legal database with a memo field called "DEFandTERMS" that houses predefined legal definitions and terms . When the user enters this memo field, a list box called "NamesList" becomes visible and displays all predefined definitions and terms for them to chose to insert into the memo field.

The code on the "DEFandTERMS" OnEnter event is:

Code:
Private Sub DEFandTERMS_Enter()
If MsgBox("Do you want to add predefined definitions?" & _
                    vbCrLf & vbCrLf & "Would you like to see them now?", _
                    vbYesNo, "Terms and Definitions") = vbYes Then
    Me.NamesList.Visible = True
    Me.testmultiselect.Visible = True
    Me.Box435.Visible = True
    Me.Label434.Visible = True
    Me.List436_Label.Visible = True
    Me.DEFCategory.Value = Null
    Me.DEFCategory.Value = Me.DEFandTERMS.Value
Me.testmultiselect.SetFocus
 End If
End Sub

The listbox is setup with a view of a field called "CategoryAbr". The definitions are housed in a field called "CategorySub" and there is a third field called "DefCateogry" that categogizes them from a-z. They are housed in a table called "DEFCategoryAll":

List Box
----------------------------------------------------
Name : NamesList
Control Source: DEFandTERMS
Row Source Type : Table/Query
Row Source : SELECT DEFCategoryAll.CategorySub, DEFCategoryAll.CategoryAbr FROM DEFCategoryAll;
Multi Select : Extended

Code:
no event procedures on listbox

Once the definitions have been selected, the user then clicks a command button to add the definitions to the memo field.

Using this code:

Code:
Private Sub testmultiselect_Click()
Dim oItem As Variant
    Dim sTemp As String
    Dim iCount As Integer
    

    iCount = 0
            
    If Me!NamesList.ItemsSelected.Count <> 0 Then
        For Each oItem In Me!NamesList.ItemsSelected
            If iCount = 0 Then
                sTemp = DEFCategory.Value & sTemp & vbCrLf & Me!NamesList.ItemData(oItem) & vbCrLf
                iCount = iCount + 1
            Else
               
                sTemp = DEFCategory.Value & vbCrLf & sTemp & vbCrLf & Me!NamesList.ItemData(oItem) & vbCrLf
                iCount = iCount + 1
            End If
        Next oItem
    Else
        MsgBox "Nothing was selected from the list", vbInformation
        Exit Sub
    End If
    Me!DEFandTERMS.Value = Trim(sTemp)
    Me.DEFCategory.Value = Null
End Sub


I also setup an unbound memo field called "DEFCategory" to be a brief catch all for definitions already housed in the "DEFandTERMS" memo field and any fromt he list box that the user chooses to add later. It has no relation to the the field in the table that the listbox is pulling from. :D Long story... but i went through several designs before finding this one that semi-works. Any help is greatly appreciated.

Ray
 
Found the issue, I had this code on the OnChange event to check for spelling:

Code:
Private Sub DEFandTERMS_Change()
If Len(Me.DEFandTERMS.Text) > 0 Then
   DoCmd.SetWarnings False
   DEFandTERMS.SelStart = 1
   DEFandTERMS.SelLength = Len(Me.DEFandTERMS.Text)
   DoCmd.RunCommand acCmdSpelling
   DEFandTERMS.SelLength = 0
   DoCmd.SetWarnings True
 End If
End Sub
 
Aside from the problem you experienced, the OnChange event is not the place for this kind of code! OnChange fires each time a character is entered in a textbox! you entered

expert

it's going to fire and find incorrect spellings

e
ex
exp
expe
exper

You need to place it in the something lie the OnExit event for the textbox.
 
Thanks for the reply...

Yep, figured out the OnChange event was not the proper place. I quickly found out that the OnExit could get annoying as well because it kept checking for stuff that i initally told it to ignore so the end result is a command button that the user will click to check spelling.

Thanks again!

Ray
 

Users who are viewing this thread

Back
Top Bottom