Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AutoKey Question 1

Status
Not open for further replies.

Noel2

Technical User
Jan 16, 2003
69
0
0
US
I am having a real difficult time figuring out how to set up an autokey. All I want to do is have a autokey set up so that when I hit control and the letter B that the following code is ran:

DoCmd.GoToRecord , , acNewRec
Form_daily_frm.dt.SetFocus

I have setup a new macro with the macro name setup as ^B and for the action I have as RunCode. Where do I go from here. I truly appreciate your assistance with my ignorance.

Thank you,
Noel
 
Noel, you may be able to do this all in the macro. For the action. First use the Action GoToRecord. This action is run against the Arguments you insert at the bottom of the Macro. The Arguments are easy to understand. Then use the GoToControl Action to move to the control on the form you want. It should be pretty easy to set up also because all you do is put in the name of the control in the Arugment space. If you have problems, post back with the specific issues. To use the RunCode Action, your code has to be in a Function and you would have to define the Form and probably add a couple other lines of code to pull it all off.

Paul
 
Thanks for the quick response Paul... I have went ahead and created the macro exactly as you described with GoToRecord being setup to goto a new record and I went to a form within the database and hit control + B and this is not going to a new record. Do you have any idea? If need be, I can send the file to you to check it out.

Thanks,
Noel
 
Noel, have you named the macro AutoKeys. You have to name it Autokeys to have it work the way you want. If you want to send it over you can. I think you have my email. If not post back. I'm on my way out for a few hours but will check in when I get home.

Paul
 
Paul,

I apologize for wasting your time on such a lame question. I can't believe I forgot to rename it to AutoKeys. Once I did this, of course this worked.

Just one simple question, is there a way that I create an AutoKey to run a public subroutine? Please let me know.

Thanks again,
Noel
 
Certainly it is possible. The subroutine would have to be a Function but that's the only catch and it really isn't a catch.

Code:
Public Sub dothis()
code...code...code
End Sub

simply becomes

Public Function dothis()
code...code...code
End Function

Then you use the RunCode Action in the macro and put the name of the Function, in this example it would be dothis(), in the Arugment.

Paul
 
Sweet!!! that is exactly what I was looking for... I just thought that functions were only meant to return a value and not to perform any actions. Thank you very much!!!

Noel
 
I like the AutoKeys feature. Most good dataentry people DON'T want to use a mouse. They prefer to keep their fingers on the keyboard and AutoKeys is a good way to help accomplish that.

Paul
 
very very true... I appreciate the assistance. This is going to be very useful in my future databases. I hate using the mouse and would much rather use the features with the autokeys. Have a great day and thanks again!

Noel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top