Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    May 2003
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Inserting a new line, then moving to that line (A97, A2k, A2k3)

    When I edit data, I open a new form. This form contains a subform that displays the data in "datasheet" view (based upon a query that links data from three tables). On the main form, I have a button that appends a new line to one of the tables (the data for the first two tables, remains the same - one to many relationship). My function appends the line correctly, and then resorts the data. However, the cursor now returns to line 1 of the data. How can I automatically move to the newly inserted line?

    TIA, Jerry

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Inserting a new line, then moving to that line (A97, A2k, A2k3)

    You'd have to store the value that identifies the new record in a variable, then use VBA code to find that value after sorting the data, similar to the code generated by the Combo Box Wizard to find a record based on the value selected in the combo box.
    If you'd like to get more specific help, I'd need to have detailed information, and preferably see a stripped down copy of the database. <post#=401925>post 401925</post#> for instructions.

  3. #3
    Lounger
    Join Date
    May 2003
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting a new line, then moving to that line (A97, A2k, A2k3)

    Attached is a sample DB that shows what I am doing today. If you run the form "frm_Edit__Modify_Mkt_Data_1024", it opens the other (sub) form "frm_Edit__Modify_Mkt_Data_sub". Move to the last line, and then single click on the "add a supplier" button. For this addition, you can simply use the default answers to each of the questions (the next time you add a supplier to the "last line", you will need to enter a unique 'supplier name'). The new record will be added, and displayed with the other supplier data records. However, the cursor will be on the first line. This is not a big issue if you only have a few records selected, but normally this query will select hundreds of lines. That is why I want to have the cursor 'move' to the line that I just added.

    One again, thanks for your assistance.

    Jerry
    Attached Files Attached Files

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Inserting a new line, then moving to that line (A97, A2k, A2k3)

    See the attached code (I put it in a text file because the lines are rather long). The code uses the idea I outlined in my previous reply.
    Attached Files Attached Files

  5. #5
    Lounger
    Join Date
    May 2003
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting a new line, then moving to that line (A97, A2k, A2k3)

    THANKS, Hans. This works great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •