Solved

Automate Open form, press Alt+R and close form

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

829 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