Solved

DoCmd.RunCommand problem.

Posted on 1998-12-18
20
599 Views
Last Modified: 2008-02-01
Hi Experts,

I have tried to use SendKeys command to
send a "Enter".
This is not a good way to do it.
The stupid NumLock turns off...
How do I send a "Enter" with
DoCmd.RunCommand ??
I have loccked at the helpfiles and have
found acCmdEnd
I think (I know) that I dont understand this...

Regards
0
Comment
Question by:helenag
20 Comments
 
LVL 7

Expert Comment

by:smilitaru
ID: 1971488
Please try again. with: SendKeys "{Enter}", True
0
 

Author Comment

by:helenag
ID: 1971489
Hi smilitaru,
I have tried and it work (bad).
I have to use this for my home made F9 key:
SendKeys "{ENTER}", True
SendKeys "{NUMLOCK}", True
But.....
if I tab down to my
home made commandbutton and press enter on the keyboard
the NumLock turn itself off....
Trygve's tip was too use DoCmd.RunCommand

Regards

0
 

Author Comment

by:helenag
ID: 1971490
But I dont know how....
(I cant understand the helpfiles in this case)
0
 
LVL 12

Expert Comment

by:Trygve
ID: 1971491
My tip was related to me guessing that you wanted to save the record (I did not explain this in the mail though)

If you tell us what you want to do, we can provide you with the proper command line.
0
 
LVL 9

Expert Comment

by:tculler
ID: 1971492
Helen,
     If what you are doing with the {Enter} keypress is to update the current record with information that you have just entered in the keyboard buffer (or in a text box on a form), the preferred method would be to use the Update method.  You can look this up in help or a book on Access using the looking for the key word Update (Update method-Access-DAO) or send me the particulars of what you are working on and I will dash out a short example and you can adapt it to your situation.

Hope this helps,

Tim





0
 
LVL 12

Expert Comment

by:Trygve
ID: 1971493
The Update method is as the name states a method of an object and can not be used directly from a form (I think). You will normally use this method from code. Something like this

Dim MyRecs as recordset
set MyRecs = currentDB.openrecordset("SELECT * FROM SomeTable")
MyRecs.edit
  MyRecs!SomeField = SomeValue
MyRecs.Update ' See ?
MyRecs.close

I you want to save the current record you should use docmd.RunCommand acCmdSaveRecord.
0
 

Author Comment

by:helenag
ID: 1971494
Listen up now....

1.I have a formed based on a table.
2.I have a lot of input fields.
3.Before I included the F9 (Keyboard button) I used to TAB down the form
to my command button "Update".
4.The "Update" commandbutton have a lot of code behind it.
5.I use the F9 key to:
a)Set focus on the commandbutton "Update"
b)I try to simulate the "Enter" button so all my code behind "Update" will run.

Question:
Can I call a Private Sub ?
If so I can call Privat sub Update_Click()........or?


Regards
0
 

Author Comment

by:helenag
ID: 1971495
Hi Tim,
Please reanswere if you like.
Regards

0
 

Author Comment

by:helenag
ID: 1971496
Adjusted points to 25
0
 
LVL 12

Accepted Solution

by:
Trygve earned 20 total points
ID: 1971497
Hope you don't mind me answering...

You may call private subs !

Call Update_Click should work just fine.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:helenag
ID: 1971498
Hi Trygve,
I have No problem at all with  that...
I begin to HATE sendkey command NOW!
The problem with my problem is that there is another company how
wrote this part of the code...

I have removed the "send key" code I included before.

but...The NumLock still making BIG trouble.. with this line:

 SendKeys "^{+}", True
 'The other programmer use this line to Update the form.
 'And I get trouble.....The NumLock now turn itself off at
 'this line (My Guess).

Workaround this should be.....?

Regards


                                   

0
 

Author Comment

by:helenag
ID: 1971499
Docmd.RunCommand acCmdSaveRecord insdead of  SendKeys "^{+}", True ?
0
 

Author Comment

by:helenag
ID: 1971500
Probebly NOT becaus I want to save form information in the table....
Not to a file.

The Update work like this:
1.The form is based on a table (Record source:TableName)
2.Cycle Current record.
3.Commandbutton "Update"
The Event procedure is:
SendKeys "^{+}", True




0
 
LVL 12

Expert Comment

by:Trygve
ID: 1971501
If the Update key has coding behind it you may use
Call Update_Click
to execute the OnClick event of the button Update if you are calling from the same form. If you are trying to execute it from somewhere else this will not be possible.

Is it possible to move the code from the Update button to a module and do something like this ?

In the Update_Click event

call DoTheUpdates

and from your F9 code

Call DoTheUpdates



Another idea. Insert an unbound hidden field. Set its AfterUpdate event to do the
Call Update_Click
set this hidden fields value from the F9 macro event. This way the hidden field will trigger the Update.
0
 
LVL 12

Expert Comment

by:Trygve
ID: 1971502
If you want you can mail me the form etc. and I will have a look at it. Trygve@Omega.no
0
 

Author Comment

by:helenag
ID: 1971503
I notice that if I CLOSED my application and returned again (after the remove of
SendKeys command) the NumLock didn't turn itself off but it "blinked"..
Did the keybord buffer something beforer or what ???
This is not fun anymore.....the christmas will be BAD for me :-(

0
 

Author Comment

by:helenag
ID: 1971504
I notice that if I CLOSED my application and returned again (after the remove of
SendKeys command) the NumLock didn't turn itself off but it "blinked"..
Did the keybord buffer something beforer or what ???
This is not fun anymore.....the christmas will be BAD for me :-(

0
 

Author Comment

by:helenag
ID: 1971505
Thanks Trygve,
I am sure we will "talk" again...
HAPPY CHRISTMAS TO YOU!


0
 
LVL 12

Expert Comment

by:Trygve
ID: 1971506
Does this mean that you have now found a solution or am I to expect an Email.

Happy Christmas to you too !
0
 

Author Comment

by:helenag
ID: 1971507
I have found a solution, not a good one but it works...
No e-mail this time.
Maby when I get into trouble again.

Chao.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now