Simulate record selection

Posted on 2004-10-28
Last Modified: 2006-11-17
I need to simulate selecting a record on a form on some event (prob after update) to update another forms OnCurrent event . Does this make sense ? it's not very easy to explain.
Question by:livvie
    LVL 58

    Accepted Solution

    No, it doesn't :)

    Just the title, "simulate record selection" makes one think of the "Edit / Select Record" menu command, which you can "simulate" (execute through code) with "RunCommand acCmdSelectRecord"

    The "explanation" however seems to relate to form navigation. Do you want to move to a certain record in a second form when editing is done in the first?

    Please expand, I'm sure we will be able to help.

    LVL 2

    Author Comment

    harfang you might actually have helped already I think the RunCommand acCmdSelectRecord might be what I am looking for.
    I have one form that shows a list of records and a second form that shows the details of these records depending on which one is selected on the first form. I had a problem with the child master relationship that was giving an "you cannot assign a value to this object error " so now the second forms datasource is updated when a selection is made on the first form.
    What I am doing now is copying a record and then I want it to be displayed and editable. Copying is fine but unless I go an click on the new record it is the details of the old record that is displayed (as this is the record selected in the first form) so I want to automatically select the new record after it is created.
    LVL 2

    Author Comment

    harfang DoCmd.RunCommand acCmdSelectRecord  works but I now need a way to ensure it runs after every copy.
    I put it in the OnDirt event and that works for the first time you copy a rec but if you do a second one it never enters the OnDirty event  Any ideas ?
    LVL 58

    Expert Comment

    Im not sure about OnDirty. Normally, a record is "dirty" after it has been changed and until it has been either saved or canceled. I do not think that paste-append ever triggers the OnDirty event.
    Try AfterInsert, perhaps.

    Another idea, can't you select the record just *before* copying it rather that *after* all editing events?

    Good Luck.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    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…
    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…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    856 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

    16 Experts available now in Live!

    Get 1:1 Help Now