SendKeys Issue on Vista

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I used the SendKey ^" function to insert data from previous record as I
enter that field.
How do I convert that function to VB code?
 
Harald Borchard said:
I used the SendKey ^" function to insert data from previous record as I
enter that field.
How do I convert that function to VB code?

Here's an example from an old help file:

This example uses the Shell function to run the Calculator application
included with Microsoft Windows.It uses the SendKeys statement to send
keystrokes to add some numbers, and then quit the Calculator. The SendKeys
statement is not available on the Macintosh. (To see the example, paste it
into a procedure, then run the procedure. Because AppActivate changes the
focus to the Calculator application, you can't single step through the
code.)

Dim ReturnValue As Variant
Dim i As Integer

ReturnValue = Shell("CALC.EXE", 1) ' Run Calculator.
AppActivate ReturnValue ' Activate the Calculator.

For I = 1 To 100 ' Set up counting loop.
SendKeys i & "{+}", True ' Send keystrokes to Calculator
Next i ' to add each value of i.

SendKeys "=", True ' Get grand total.
SendKeys "%{F4}", True ' Send ALT+F4 to close Calculator.
 
Arvin, Thanks for your quick reply. Unfortunately it's not what I'm after. I
need a function without SendKeys at all as Vista has a problem with it.
Harald
 
If you want a control to routinely default to the value in the previously
entered record, set the control's DefaultValue property to its Value property
in the control's own AfterUpdate event.

John W. Vinson [MVP]
 
Hi Harald

I had the same problem. I had previously used the sendkeys/autokeys
combination so the operator could simply press F11 and the value from
previous record would be inserted into the current field automatically - by
adding TAB the operator was automatically placed into the next field.
(^'{tab}). Changing to the default value method wasn't an option because we
sometimes wanted this functionality and at other times we didn't. Using the
F11 option gave the operator the ability to copy the previous record's value
in "any" field as appropriate.

I tried various workarounds and in the end took up the M8 software solution
http://www.m8software.com/developer/keysend/sendkey.htm at a cost of $US95

It is working very well, just changed the procedure to a function and
entered a pause. We also use autokeys to enter text in a similar way to
autotext in Word so we could implement this as well. Sorry because of their
M8's copyright I cannot paste code here but they did offer me a return on my
money if I wasn't happy.

Regards
Di
 
There are several ways to add data from a previous record. If you are in
datasheet or continuous form view, you can use the Ctrl + " (double-quote)
keys to insert data just like in Excel. You can also set the default value
of the next record in the AfterUpdate event of the control you are entering
data in, with the line of code:

This will work for all data types.

Set the defaultvalue for any datatype with 4 double-quotes:

ControlName.DefaultValue="""" & ControlName & """"
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
Back
Top