UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Back Space From Cursor, Access 2016    
 
   
payfast8898
post Jan 18 2020, 03:54 PM
Post#1



Posts: 394
Joined: 23-April 15
From: NY


does anyone have code to do a back space from the cursor location. NOT from the end of the string i can do that OK.

We have an keyboard that brings up clients on keystrokes we don't want to use the windows one in case anyone ask.

We would just like to put the cursor in the middle of a word or sentence and start back spacing from there. i couldn't find much help on line.

Thank you.

--------------------
"When a collection of Brilliant minds, hearts and talents come together...
Expect a masterpiece"
Go to the top of the page
 
GroverParkGeorge
post Jan 18 2020, 05:42 PM
Post#2


UA Admin
Posts: 36,782
Joined: 20-June 02
From: Newcastle, WA


How do you decide what constitutes "the middle of a word or sentence"?

You can use SelStart and SelLength to place the cursor at specific locations in a string. However, the requirement could be a bit vague for a specific approach. The problem is that there will have to be some level of human decision making about that starting point.


--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
payfast8898
post Jan 18 2020, 06:28 PM
Post#3



Posts: 394
Joined: 23-April 15
From: NY


if i put the mouse arrow between the r|s in cursor and want to back space to get ride of the r so it it said cusor or if i typed "The the back space don't work" i would like to put the cursor in front of the second "the" and back space. nothing to complex.

--------------------
"When a collection of Brilliant minds, hearts and talents come together...
Expect a masterpiece"
Go to the top of the page
 
GroverParkGeorge
post Jan 18 2020, 06:52 PM
Post#4


UA Admin
Posts: 36,782
Joined: 20-June 02
From: Newcastle, WA


Okay then.

1) Manually place the cursor in a specific place.
2) Push a button to erase from that location back to the first position of the text in that control.

I think there are probably two or three ways to do that.

Let's see what comes up. The way I would NOT do would be with SendKeys, but otherwise there should be a simple way.

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
payfast8898
post Jan 18 2020, 07:20 PM
Post#5



Posts: 394
Joined: 23-April 15
From: NY


yes no send keys please

--------------------
"When a collection of Brilliant minds, hearts and talents come together...
Expect a masterpiece"
Go to the top of the page
 
GroverParkGeorge
post Jan 18 2020, 07:29 PM
Post#6


UA Admin
Posts: 36,782
Joined: 20-June 02
From: Newcastle, WA


This little sample shows one possible way to do it. There should be others, I'm sure.

Attached File  AutoCursorDelete.zip ( 27.16K )Number of downloads: 1

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
jleach
post Jan 18 2020, 08:17 PM
Post#7


UtterAccess Administrator
Posts: 10,454
Joined: 7-December 09
From: St. Augustine, FL


I haven't looked at George's code and may be duplicating ideas here, but as a general first approach I'd do something like this:

1. get the full length of the string in question
2. get the cursor position (and select length, might as well)
3. get the Left() up to the select start
4. get the Right() after the select start + select length
5. replace the current value with the concatenation of steps 3 and 4
6. (optionally) reset the cursor position as needed

--------------------
Jack D. Leach
Founder & CEO
Dymeng Services Inc.
Business Software Solutions
Go to the top of the page
 
payfast8898
post Jan 18 2020, 10:24 PM
Post#8



Posts: 394
Joined: 23-April 15
From: NY


groverparkgeorge it deletes everything to the left of the cursor not just the one letter.
Jleach yes we should be able to divide the two parts of the text on each side of the cursor and then put them back together Left -1 some how i just don't know how to write it.

--------------------
"When a collection of Brilliant minds, hearts and talents come together...
Expect a masterpiece"
Go to the top of the page
 
jleach
post Jan 18 2020, 10:40 PM
Post#9


UtterAccess Administrator
Posts: 10,454
Joined: 7-December 09
From: St. Augustine, FL


Are you familiar with string manipulation functions?

Left()
Right()
Mid()
InStr()
Len()

then the properties of the textbox in which the cursor is placed:

.SelStart
.SelLength

thus, you write a generic function that returns the value you want:

CODE
Public Function RemoveSelectionOrPreviousCharacter(InputString As String, SelStart As Integer, SelLength As Integer) As String
  'returns the original input string, less the selection, or if there's no selected characters, less the character to the left of the cursor
  ...
  ...
End Function


then you can call it like this (aircode...):

CODE
With Me.MyTextBox
  .Text = RemoveSelectionOrPreviousCharacter(.Text, .SelStart, .SelLength)
End With


that's the basic structure of things. Then fill in your body a bit (aircode again):

CODE
Dim LeftPart as String
Dim RightPart as String

LeftPart = Left(InputString, SelStart)
RightPart = Right(InputString, Len(InputString) - SelStart + SelLenth)

Result = LeftPart + RightPart


Add offsets as required until it comes out right. Add a condition in there to see if there's selected text or not. Check if SelStart and SelLength are 0-based, handle accordingly. Handle the case where the cursor is at the beginning, etc etc.

The rest is just testing and tweaking. hth

--------------------
Jack D. Leach
Founder & CEO
Dymeng Services Inc.
Business Software Solutions
Go to the top of the page
 
payfast8898
post Jan 18 2020, 10:41 PM
Post#10



Posts: 394
Joined: 23-April 15
From: NY


This is the basics code i use to insert a letter into where my cursor is i just can't figure out how to backspace it

CODE
Option Compare Database
Option Explicit
Dim lngCursorPos As Long
Dim strText1 As String
Dim strInsert As String
Dim strText2 As String


CODE
Function CheckCursorPos()
lngCursorPos = Me.txtLastName.SelStart
End Function]


CODE
Dim lngNewCursorPos As Long
strInsert = "b"
lngNewCursorPos = Len(strText1 & "" & strInsert & "")
Me.txtLastName = strText1 & "" & strInsert & "" & strText2
Me.txtLastName.SetFocus
Me.txtLastName.SelStart = lngNewCursorPos
Call CheckCursorPos

This post has been edited by payfast8898: Jan 18 2020, 10:45 PM

--------------------
"When a collection of Brilliant minds, hearts and talents come together...
Expect a masterpiece"
Go to the top of the page
 
GroverParkGeorge
post Jan 18 2020, 11:25 PM
Post#11


UA Admin
Posts: 36,782
Joined: 20-June 02
From: Newcastle, WA


Hm. I must have misread your original post.

But now that I see you only want to delete a single character, I can't imagine why you'd want to go to the trouble of writing code to do that? Wouldn't you just use the keyboard?

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
GroverParkGeorge
post Jan 18 2020, 11:39 PM
Post#12


UA Admin
Posts: 36,782
Joined: 20-June 02
From: Newcastle, WA


Oh, I see that you also said you DON'T want to use "the Windows one". Are we talking about an on-screen keyboard instead of a physical one then?

Otherwise, I'm still confused about the goal.

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
payfast8898
post Jan 19 2020, 08:50 AM
Post#13



Posts: 394
Joined: 23-April 15
From: NY


yes we use it for our bar software and the girls hate having to delete all the characters before the mistake they made especially when busy.

--------------------
"When a collection of Brilliant minds, hearts and talents come together...
Expect a masterpiece"
Go to the top of the page
 
GroverParkGeorge
post Jan 19 2020, 09:50 AM
Post#14


UA Admin
Posts: 36,782
Joined: 20-June 02
From: Newcastle, WA


"... we use it for our bar software ..."

Since I don't know what that bar software is, I'm going to venture a couple of thoughts.

First, I assume that you're talking about a touch screen, right? And an on-screen keyboard to support it, right?

And here's a leap, are you using some sort of kiosk to key in drink orders in a bar?

At this point, I'd have to repeat what I said before about human judgement.

"...delete all the characters before the mistake they made..."

But that is what my little demo did, and you rejected that option. So, if it's not really "all", but only "some", you have a different, and harder challenge.

There could be one wrongly typed character, or many. So having an automated process to delete one or more characters, based not on some objective measure but on the HI (Human Intelligence) required to recognize mistakenly typed characters does seem like a really big challenge.

As an aside, one of my big pet peeves about keyboards on smart phones is exactly this. It's really, really hard to delete X characters at once, rather than one at a time.

In other words, whatever you do, a bar tender who has mistakenly typed one or more characters has to decide where to start with the replacement and how many characters to delete, do they not? Plus, there's no reliable way to predict whether that will be one or twenty on any given occasion. I'll be honest. I'd say your time would be better invested in an alternative approach instead of trying to second-guess mistakes that need to be removed.

Perhaps a drop-down list of acceptable choices would limit typing errors in some places, for example.

This all goes back to one of the basic premises of computers, poetry, humor and politics. Ambiguity is fine in only all three of the four.....
This post has been edited by GroverParkGeorge: Jan 19 2020, 10:02 AM

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
payfast8898
post Jan 19 2020, 02:40 PM
Post#15



Posts: 394
Joined: 23-April 15
From: NY


GroverParkGeorge not really sure what you where trying to say i was just trying to make my on screen keyboard work like a real keyboard with the backspace key? Anyway i knew i was really close but my brain was tired and usually if i post it up here people keep me on track or at least works as a great sounding board.

I figured it out so now i can back space like a big boy keyboard lol. Anyways i trimmed one up and uploaded it in case anyone needs one it really works well.


CODE
Dim lngNewCursorPos As Long
lngNewCursorPos = Len(strText1) - 1
Dim ntx
ntx = Left(Me.txtLastName, lngNewCursorPos)
Me.txtLastName = ntx & strText2
Me.txtLastName.SetFocus
Me.txtLastName.SelStart = lngNewCursorPos
Call CheckCursorPos



If you need to have every word after the space bar to capitalize, we do because we use a lot of first and last names to type in there, or you can make a toggle button or something to control that but i have that blocked.

CODE
'Toggle15 = True
'Toggle71 = Toggle15
'caps

This post has been edited by payfast8898: Jan 19 2020, 02:42 PM
Attached File(s)
Attached File  keyboard.JPG ( 98.89K )Number of downloads: 5
Attached File  Keyboard.zip ( 47.75K )Number of downloads: 1
 

--------------------
"When a collection of Brilliant minds, hearts and talents come together...
Expect a masterpiece"
Go to the top of the page
 
GroverParkGeorge
post Jan 19 2020, 04:59 PM
Post#16


UA Admin
Posts: 36,782
Joined: 20-June 02
From: Newcastle, WA


I finally see what you're trying to do. You want to code a button in your on-screen keyboard to behave like the backspace key on the keyboard. Sorry, until you showed us the actual screenshot, that wasn't quite clear.

Congratulations on solving the problem.

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
cheekybuddha
post Jan 20 2020, 04:53 AM
Post#17


UtterAccess Moderator
Posts: 12,343
Joined: 6-December 03
From: Telegraph Hill


Looks like you could usefully use left and right arrow buttons. There's nothing more annoying than having to backspace and then re-type a load of characters when the single mistake was a few a few characters back!

--------------------


Regards,

David Marten
Go to the top of the page
 
cheekybuddha
post Jan 20 2020, 04:54 AM
Post#18


UtterAccess Moderator
Posts: 12,343
Joined: 6-December 03
From: Telegraph Hill


Also, why have 2 '.com' buttons?

--------------------


Regards,

David Marten
Go to the top of the page
 
payfast8898
post Jan 20 2020, 06:27 AM
Post#19



Posts: 394
Joined: 23-April 15
From: NY


LOL this was not the one we use in the pos that has too much coding to take out i just imported from one of our test files, we have arrows left and right and home and end. not sure why this one has two .com's probably wasn't finished or forgot about but thanks for pointing it out, oh i see they have www. in our pos one in the upper one.

--------------------
"When a collection of Brilliant minds, hearts and talents come together...
Expect a masterpiece"
Go to the top of the page
 
jleach
post Jan 20 2020, 07:01 AM
Post#20


UtterAccess Administrator
Posts: 10,454
Joined: 7-December 09
From: St. Augustine, FL


Well you can't possibly remove it now!

https://xkcd.com/1172/

--------------------
Jack D. Leach
Founder & CEO
Dymeng Services Inc.
Business Software Solutions
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    24th February 2020 - 05:52 PM