?
Solved

DoCmd.RunCommand problem.

Posted on 1998-12-18
20
Medium Priority
?
653 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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 60 total points
ID: 1971497
Hope you don't mind me answering...

You may call private subs !

Call Update_Click should work just fine.
0
 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

752 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