Simulating a key press

mugman17

Registered User.
Local time
Today, 16:02
Joined
Nov 17, 2000
Messages
110
Is there a way to simulated through VB that someone pressed control and apostrophe and the same time.

How would I get this to be added into a certain field:

ie: Quantity.Value = (Press the ctrl and apostrophe keys)

The client wants this automated. To fill in 3 fields if needed. So I would do it through a command button.
 
are you trying to generate accented characters by any chance?

al
 
I am trying to add the value from the last record into a couple text boxes. I have ran out of ideas, so I figured I could perhaps simulate the pressing of ctrl and apostrophe in 5 different controls and have it bring up the previous records' value.
 
the more robust approach would probably be using autofill.

do a search for it on this board...

you also might use the 'dreaded' sendkeys, however i don't think you can do this from a command button as the control in question probably has to have the focus.

kinda ugly, but should work... :)
you might try using the double click event for the control and do:

SendKeys "^'", True (the value in the string is the ^ (caret) and the apostrophe"


hth,
al
 
Last edited:
I tried to autofill to work properly, but could not. As it is based on if the user needs it autofilled or not, he would click a command button. Most samples I see have something in the OnCurrent Event of the form, which I tried to put into a command button with no luck.
 
mugman17,

-----you wrote-----
The client wants this automated. To fill in 3 fields if needed. So
I would do it through a command button.
-------------------

imho, to do this you will have to use the autofill...

-----you wrote-----
I tried to autofill to work properly, but could not.
-------------------

to help you, we need to know what went wrong when you tried to use autofill. autofill is not all that easy to use.

does you client ALWAYS want all 3 fields completed by autofill, or maybe just 1 or 2?

if not always all 3, then the sendkeys may be the way to go.


al
 
Thanks for your help. I used a command button where I used SetFocus for each control then I used the SendKeys to add the previous record. Works like a charm. Thanks again.
 
mugman17,

sendkeys is kind of a 'last-ditch' effort...when nothing else works.

happy to be of help...

i learned something as well, i didn't think you could use sendkeys on a command button with setfocus to multiple controls!

so thank you too :)

al
 
One more thing, do you know of a way to get a previous records' value into an unbound text box. Would I need to do a DLookup? As I think the SendKeys method only relates to fields of the same name.

I think this might be tough.
 
dlookup is probably your best shot.

it is sometimes difficult to get the previous record depending on your table structure, ie is the table's PK an autonumber or what...so Dmax might also be an option.

al
 
DO you have any thoughts on the syntax?

DLookup("TotalBuyerAmount","Inventory Transactions", where the TotalBuyerAmount equals last record)

Not a clue on how to code the criteria.
 

Users who are viewing this thread

Back
Top Bottom