When the user enters the memo field on a form I have it selects all the text.
This is dangerous because they might overwrite all the contents of that memo field with a keystroke.
How do I prevent this from happening?
When the user enters the memo field on a form I have it selects all the text.
This is dangerous because they might overwrite all the contents of that memo field with a keystroke.
How do I prevent this from happening?
'Behavior Entering Field' is a user defined/controlled option and if the 'Select Entire Field' option is chosen, by any user, that's the behavior they'll get, and yes, it is dangerous! What you can do, to prevent this on all users, is something like this, replacing all instances of MyMemoField with the actual name of your Memo Field Textbox:
Code:Private Sub MyMemoField_Click() If IsNull(Me.MyMemoField.Value) Then Me.MyMemoField.SelStart = 0 End If If Not IsNull(Me.MyMemoField.Value) Then If Len(Me.MyMemoField.Value) < 32767 Then Me.MyMemoField.SelStart = Len(Me.MyMemoField.Value) Else Me.MyMemoField.SelStart = 0 End If End If End Sub Private Sub MyMemoField_GotFocus() If IsNull(Me.MyMemoField.Value) Then Me.MyMemoField.SelStart = 0 End If If Not IsNull(Me.MyMemoField.Value) Then If Len(Me.MyMemoField.Value) < 32767 Then Me.MyMemoField.SelStart = Len(Me.MyMemoField.Value) Else Me.MyMemoField.SelStart = 0 End If End If End Sub
This will set the cursor to the end of the data, until it reaches 32767 characters, at which time it will place the cursor at 32767 characters. The used SelStart takes an Integer as an argument, and 32767 is the limit for Integers, so you cannot set it beyond there. But let's be honest, it's seldom that a Memo Field is actually going to surpass that limit!
Linq ;0)>
I'm thinking this is a windows control option? If so how do I get around it? Or is it a setting in access? If so I have a problem because I am using runtime and will have to implement your code.'Behavior Entering Field' is a user defined/controlled option and if the 'Select Entire Field' option is chosen, by any user, that's the behavior they'll get, and yes, it is dangerous! What you can do, to prevent this on all users, is something like this, replacing all instances of MyMemoField with the actual name of your Memo Field Textbox:
Code:Private Sub MyMemoField_Click() If IsNull(Me.MyMemoField.Value) Then Me.MyMemoField.SelStart = 0 End If If Not IsNull(Me.MyMemoField.Value) Then If Len(Me.MyMemoField.Value) < 32767 Then Me.MyMemoField.SelStart = Len(Me.MyMemoField.Value) Else Me.MyMemoField.SelStart = 0 End If End If End Sub Private Sub MyMemoField_GotFocus() If IsNull(Me.MyMemoField.Value) Then Me.MyMemoField.SelStart = 0 End If If Not IsNull(Me.MyMemoField.Value) Then If Len(Me.MyMemoField.Value) < 32767 Then Me.MyMemoField.SelStart = Len(Me.MyMemoField.Value) Else Me.MyMemoField.SelStart = 0 End If End If End Sub
This will set the cursor to the end of the data, until it reaches 32767 characters, at which time it will place the cursor at 32767 characters. The used SelStart takes an Integer as an argument, and 32767 is the limit for Integers, so you cannot set it beyond there. But let's be honest, it's seldom that a Memo Field is actually going to surpass that limit!
Linq ;0)>
Note: runtime does not have those options to customize the client
Have never used RunTime so have no idea vis-à-vis setting options. It is an Access Option, found under Options - Advanced - Behavior Entering Field. But using the code I gave will control the behavior of the Memo Field Control, within the limitation I gave you.
Linq ;0)>
I solved it. You use this on the very first form that is loaded. It then saves the setting for the rest of the forms unless otherwise specified. This is the only way I can see it possible for runtime.Private Sub Form_Load()Application.SetOption "Behavior Entering Field", 1
End Sub
Glad you got it knocked! Have you actually tested it? I ask because many times when you set the Application Options (through code or on the Ribbon) they don't actually kick in until Access is closed then re-opened. Even so, that would only leave you at risk the first time a user opened the db. Also would be interesting to know if the Access Gnomes consider setting the App Options to be 'design changes,' which are verboden in RunTime, if I remember correctly; but as I said, I've never really used RunTime.
Linq ;0)>
Yeah it works, all the staff have been using their front ends all day today without a hitch. I thought about to what extent you can bring back options through runtime (contextual menu for right click for example) but haven't played around with it thus far.Glad you got it knocked! Have you actually tested it? I ask because many times when you set the Application Options (through code or on the Ribbon) they don't actually kick in until Access is closed then re-opened. Even so, that would only leave you at risk the first time a user opened the db. Also would be interesting to know if the Access Gnomes consider setting the App Options to be 'design changes,' which are verboden in RunTime, if I remember correctly; but as I said, I've never really used RunTime.
Linq ;0)>
I am still trying to work out popup to front for forms but with print options. If I remove popup I get back the print options but then the forms open behind the previous form.
I do like using vba to set that option - even if they have Access in the full they are forced by default to use the option I choose (great if someone forgets to adjust their settings).
Ruegen,
I offered a right click menu in the other thread you started. I uploaded a file that can be imported to your accdb and then utilized during RT. There are three menus, including a right click shortcut that can be assigned to Popup/Modal Forms/Reports.
The code offered in this thread by Missinglinq should work just fine in RT. In fact, RT is all about using VBA to get things done. The code offered in this thread should work just fine in a subroutine for a form. Using .SelStart is usually not something I would put in a Genearal Module as a public function. There is a reason Missinglinq placed .SelStart in two subroutines. It needs to monitor the User's actions and would slow things down as a Public Function.
I'll have a look into that ItsMe - forgive me if I take a while to respond (I'm overwhelmed with workRuegen,
I offered a right click menu in the other thread you started. I uploaded a file that can be imported to your accdb and then utilized during RT. There are three menus, including a right click shortcut that can be assigned to Popup/Modal Forms/Reports.
The code offered in this thread by Missinglinq should work just fine in RT. In fact, RT is all about using VBA to get things done. The code offered in this thread should work just fine in a subroutine for a form. Using .SelStart is usually not something I would put in a Genearal Module as a public function. There is a reason Missinglinq placed .SelStart in two subroutines. It needs to monitor the User's actions and would slow things down as a Public Function.) usually I don't even like asking for help and I ask 1% on this forum and work the 99% out myself. I will get to it very soon but I thank you kindly for you help.