DoCmd.RunCommand problem.

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
helenagAsked:
Who is Participating?
 
TrygveCommented:
Hope you don't mind me answering...

You may call private subs !

Call Update_Click should work just fine.
0
 
smilitaruCommented:
Please try again. with: SendKeys "{Enter}", True
0
 
helenagAuthor Commented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
helenagAuthor Commented:
But I dont know how....
(I cant understand the helpfiles in this case)
0
 
TrygveCommented:
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
 
tcullerCommented:
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
 
TrygveCommented:
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
 
helenagAuthor Commented:
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
 
helenagAuthor Commented:
Hi Tim,
Please reanswere if you like.
Regards

0
 
helenagAuthor Commented:
Adjusted points to 25
0
 
helenagAuthor Commented:
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
 
helenagAuthor Commented:
Docmd.RunCommand acCmdSaveRecord insdead of  SendKeys "^{+}", True ?
0
 
helenagAuthor Commented:
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
 
TrygveCommented:
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
 
TrygveCommented:
If you want you can mail me the form etc. and I will have a look at it. Trygve@Omega.no
0
 
helenagAuthor Commented:
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
 
helenagAuthor Commented:
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
 
helenagAuthor Commented:
Thanks Trygve,
I am sure we will "talk" again...
HAPPY CHRISTMAS TO YOU!


0
 
TrygveCommented:
Does this mean that you have now found a solution or am I to expect an Email.

Happy Christmas to you too !
0
 
helenagAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.