Solved

Automate Open form, press Alt+R and close form

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

733 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