Solved

Automate Open form, press Alt+R and close form

Posted on 2013-12-01
4
294 Views
Last Modified: 2014-10-29
Hi all,

I need a (event) button on the main form to open a form in ms access, the combination alt R has to be automatically entered and the form needs to close after the data has bean .

The combination keys "alt r" is needed to read data from the barcode reader.

After reading  the data in the opend form another subform on the main form needs to reload because the data that is entered needs to show the new data.

thanks!

I have the code for the On click event but th code for the shortkey and reloading the suborm is missing

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Offer"
    DoCmd.OpenForm BarcodeDataForm, , , stLinkCriteria

 DoCmd.Close acForm, BarcodeDataForm

Open in new window


I have found custom MySendkeys But don't know how to use it.
0
Comment
Question by:mvdwal
4 Comments
 
LVL 20

Accepted Solution

by:
GrahamMandeno earned 500 total points
ID: 39688773
Hi mvdwal

You should open your form modally which means that the code which opens it will not continue to execute until the form is closed or made invisible.  Then you can requery the subform:
Private Sub cmdReadBarcode_Click()
    DoCmd.OpenForm "BarcodeDataForm", WindowMode:=acDialog
    Me.[SubformControlName].Form.Requery
End Sub

Open in new window


I assume that BarcodeDataForm is opening in DataEntry mode and adding a new record to a table.  You would probably be best to use the GotFocus event of the textbox to send the Alt-r, and use the AfterUpdate event of the same textbox to save the record and close the form:
Private Sub txtBarcode_GotFocus()
    SendKeys "%r"
End Sub

Private Sub txtBarCode_AfterUpdate()
    RunCommand acCmdSaveRecord
    DoCmd.Close acForm, Me.Name
End Sub

Open in new window

Good luck :-)
Graham Mandeno [Access MVP since 1996]
0
 

Author Comment

by:mvdwal
ID: 39692130
Dear Graham Mandeno,

Thanks a lot! I will try your method this week! I'll keep you posted!
Kind regards,
Michiel
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

757 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

21 Experts available now in Live!

Get 1:1 Help Now