[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

DoCmd.RunCommand problem.

Posted on 1998-12-18
20
Medium Priority
?
657 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

656 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