1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Setting focus on second form

Discussion in 'Business Applications' started by Rockn, Feb 1, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. Rockn

    Rockn Thread Starter

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    I have a continuous form with a set of records returned. I want to use the onDBClick event to open another form and set the focus to the item that was doulble clicked in the previous form. The first form has the selection PK listed in a hidden text box

    Images attached
     

    Attached Files:

  2. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Rockn, do you have it already "Opening" the form on the required Vendor?
    The way that I would do this is to actually have a dedicated form, which is a copy of a current form, but uses a different Query, in the Query I would use the Criteria row to filter the data to the Current Vendor and Current Item double clicked. (Or use SQL to do the same thing)

    The other way to do this is to have some VBA in the second Forms "On Current" event procedure which uses a recordset clone to "Find" the correct record and then sets the form's Bookmark to the found record. But you do not want it to do this if the form is used for other functions, so you will need to add a hidden field on the form that is updated by the VBA that opens the form indicating that the focus has come from your first form.
    Then when the form is closed it resets that field back to "".
     
  3. Rockn

    Rockn Thread Starter

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    I have the initial formopening the second form based on the Job_ID and it opens the second form pased on the selections for that job with the main forms JOB_ID

    I want to be able to double click any item in the list, have it open the second form with the focus set on the item that was double clicked.

    I will try the second suggestion as it seems like it might be what I need.
     
  4. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Rockn, the first method is much simpler and works like a charm.
    The only downside is a duplicated from and query, assuming that you use that form for something else.
    I would urge you to try that first, is just means creating a query for your form that has the "Item Number" field as the Criteria Row for the Item Number Column.
    It takes the format of
    [forms]![First Form Name]![Item Number]
    where [First Form Name" is the name of the Form that you double click the Item Number on.
    It is very fast and just brings up the record(s) that match the Item Number, so no Setting of focus is necessary.
     
  5. Rockn

    Rockn Thread Starter

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    The second form that is being brought up is opening the table directly for editing with all items for a given job, not just the item being clicked on. All of the rows returned in the second image are a recordset based on the job and the items belonging to that job.

    The form is used in two different ways, but it may be easier to just use the onDbls click to filter the form down to a single item for editing. I also have another button on the main form named "edit selections" that brings up all items for the job. This may be a more simple solution altogether instead of setting the focus to on item in the collection of items.
     
  6. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Rockn, by the way I like the "Style" of your forms, I am not good at the arty stuff, just plain, but functional.(y)
     
  7. Rockn

    Rockn Thread Starter

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    There is style?? A bunch of women will be using it so I had to make it purty. Think I'll add some flowers.

    I think this might not work the way I want because of the continous form. I might have to rethink this and either make the main form use a list box or just leave well enough alone.
     
  8. Rockn

    Rockn Thread Starter

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    I almost have it licked. I am having problems with the OpenReport criteria using an AND

    Private Sub MFG_NAME_DblClick(Cancel As Integer)

    Dim jobID As String

    jobID = "SEL_ID = " & Me.selID & " AND " & JOB_ID = " & Me.JOB_ID"


    DoCmd.OpenForm "frm_EditSelections", acNormal, , jobID

    End Sub

    It is probably something to do with single or double quotes. I open the second form with this and it says filter false so my syntax is messed up.
     
  9. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    I told you it was easier with the Query.
    I have never used a double Criteria in the Form open expression.
    You could try
    jobID = "SEL_ID = " & Me.selID & " & AND & " & JOB_ID = " & Me.JOB_ID"
     
  10. Rockn

    Rockn Thread Starter

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Well, since the SEL_ID is unique to the record no matter the job I just filtered it to SEL_ID alone and it works great. Problem solved...I just copied the old form and set it's proterties to edit only for the current record so they cannot add another(which would throw an error) or delete the current record.

    My forms collection sure is growing....;)
     
  11. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Well done, give yourself a "pat on the back". (y)
     
  12. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - Setting focus second
  1. DebbyR
    Replies:
    3
    Views:
    336
  2. vicks
    Replies:
    0
    Views:
    275
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/540280

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice