Solved

DoCmd.RunCommand problem.

Posted on 1998-12-18
20
622 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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
 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
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…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 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