Connecting Tech Pros Worldwide Forums | Help | Site Map

How to restore cursor position after acSaveRecord?

(Pete Cresswell)
Guest
 
Posts: n/a
#1: Nov 13 '05
Right now, as the user types I'm invoking this code in the field's Change event:
-----------------
With theField
cursorPos = .SelStart
Application.RunCommand acCmdSaveRecord
.SelStart = cursorPos
End With
-----------------

The idea is that there may be a floater window open that's linked to the same
field and I want the user's typing to show up immediately in both windows.

The code above works...sort of.... but it seems TB swallowing SpaceBars. i.e.
If somebody types "xyz" it works OK. But if somebody types "x y z", what gets
to the field is only "xyz".

I tried .SelStart = cursorPos + 1, but it didn't help...seems like the spaces
just aren't there at that time...yet amphamerics are...

?
--
PeteCresswell

Steve Jorgensen
Guest
 
Posts: n/a
#2: Nov 13 '05

re: How to restore cursor position after acSaveRecord?


When you ask Access to save the record, it also finalizes the field edit.
Access trims trailing blanks from data entered by hand into a field, so the
space character is lost. I think you will have to cache the value of the
field's Text property before the acCmdSaveRecord, then use the field's
AfterUpdate handler to re-write it to the control.

Another option would be to update the floater window differently so that you
can use the Text property to update the floating window (floater sounds like a
corpse to me <g>) immediately rather than having to save the entire record.

On Mon, 20 Dec 2004 00:18:46 GMT, "(Pete Cresswell)" <x@y.z> wrote:
[color=blue]
>Right now, as the user types I'm invoking this code in the field's Change event:
>-----------------
> With theField
> cursorPos = .SelStart
> Application.RunCommand acCmdSaveRecord
> .SelStart = cursorPos
> End With
>-----------------
>
>The idea is that there may be a floater window open that's linked to the same
>field and I want the user's typing to show up immediately in both windows.
>
>The code above works...sort of.... but it seems TB swallowing SpaceBars. i.e.
>If somebody types "xyz" it works OK. But if somebody types "x y z", what gets
>to the field is only "xyz".
>
>I tried .SelStart = cursorPos + 1, but it didn't help...seems like the spaces
>just aren't there at that time...yet amphamerics are...
>
>?[/color]

Wayne Morgan
Guest
 
Posts: n/a
#3: Nov 13 '05

re: How to restore cursor position after acSaveRecord?


The problem is that when Access saves the record, it will trim any trailing
spaces. One way around this would be to not save if the last character was a
space. Another way would be to have a Static variable in the routine to
"remember" what was actually in the box and when the next non-space is
typed, have it replace everything. Either way, you won't get "A " showing up
in your other form.

What are you trying to do that you need to force the updates onto the other
form like this?

--
Wayne Morgan
Microsoft Access MVP


"(Pete Cresswell)" <x@y.z> wrote in message
news:3i6cs05va058qlsc4e22d7g1hcfuimr14q@4ax.com...[color=blue]
> Right now, as the user types I'm invoking this code in the field's Change
> event:
> -----------------
> With theField
> cursorPos = .SelStart
> Application.RunCommand acCmdSaveRecord
> .SelStart = cursorPos
> End With
> -----------------
>
> The idea is that there may be a floater window open that's linked to the
> same
> field and I want the user's typing to show up immediately in both windows.
>
> The code above works...sort of.... but it seems TB swallowing SpaceBars.
> i.e.
> If somebody types "xyz" it works OK. But if somebody types "x y z", what
> gets
> to the field is only "xyz".
>
> I tried .SelStart = cursorPos + 1, but it didn't help...seems like the
> spaces
> just aren't there at that time...yet amphamerics are...
>
> ?
> --
> PeteCresswell[/color]


Closed Thread