Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-07-2002, 10:29 AM   #1
mugman17
Registered User
 
Join Date: Nov 2000
Location: Calgary, Canada
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
mugman17
Simulating a key press

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.

mugman17 is offline   Reply With Quote
Old 07-07-2002, 11:18 AM   #2
pcs
Senior Member
 
pcs's Avatar
 
Join Date: May 2001
Location: USA,Indiana,Technology Backwater
Posts: 398
Thanks: 0
Thanked 0 Times in 0 Posts
pcs
are you trying to generate accented characters by any chance?

al
pcs is offline   Reply With Quote
Old 07-07-2002, 11:35 AM   #3
mugman17
Registered User
 
Join Date: Nov 2000
Location: Calgary, Canada
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
mugman17
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.

mugman17 is offline   Reply With Quote
Old 07-07-2002, 12:39 PM   #4
pcs
Senior Member
 
pcs's Avatar
 
Join Date: May 2001
Location: USA,Indiana,Technology Backwater
Posts: 398
Thanks: 0
Thanked 0 Times in 0 Posts
pcs
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 by pcs; 07-07-2002 at 12:41 PM.
pcs is offline   Reply With Quote
Old 07-07-2002, 01:04 PM   #5
mugman17
Registered User
 
Join Date: Nov 2000
Location: Calgary, Canada
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
mugman17
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 is offline   Reply With Quote
Old 07-07-2002, 03:41 PM   #6
pcs
Senior Member
 
pcs's Avatar
 
Join Date: May 2001
Location: USA,Indiana,Technology Backwater
Posts: 398
Thanks: 0
Thanked 0 Times in 0 Posts
pcs
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
pcs is offline   Reply With Quote
Old 07-07-2002, 05:02 PM   #7
mugman17
Registered User
 
Join Date: Nov 2000
Location: Calgary, Canada
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
mugman17
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 is offline   Reply With Quote
Old 07-07-2002, 07:33 PM   #8
pcs
Senior Member
 
pcs's Avatar
 
Join Date: May 2001
Location: USA,Indiana,Technology Backwater
Posts: 398
Thanks: 0
Thanked 0 Times in 0 Posts
pcs
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
pcs is offline   Reply With Quote
Old 07-08-2002, 05:34 AM   #9
mugman17
Registered User
 
Join Date: Nov 2000
Location: Calgary, Canada
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
mugman17
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.
mugman17 is offline   Reply With Quote
Old 07-08-2002, 08:15 AM   #10
pcs
Senior Member
 
pcs's Avatar
 
Join Date: May 2001
Location: USA,Indiana,Technology Backwater
Posts: 398
Thanks: 0
Thanked 0 Times in 0 Posts
pcs
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
pcs is offline   Reply With Quote
Old 07-08-2002, 08:34 AM   #11
mugman17
Registered User
 
Join Date: Nov 2000
Location: Calgary, Canada
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
mugman17
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.

mugman17 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 08:18 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World