Solved

Automate Open form, press Alt+R and close form

Posted on 2013-12-01
4
304 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

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

943 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

9 Experts available now in Live!

Get 1:1 Help Now