Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Form running queries to open another form

  1. #1
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    371

    Form running queries to open another form

    Hello,



    I have a form where someone can enter value into it and click to run the query then it opens up a second form.

    Sometimes depends on what is inputted, sometimes the second form is open but ended up being behind the scene instead. It should pop open and be the form on top. Hope you understand what I mean.

    I am not sure why or how I can fix it. Pretty disappointing when it does that because I was hoping for a sound program.

    Please advise.

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    7,384
    in a form that shows all records, enter the search term into a text box, then on the afterupdate event, filter the findings:
    Code:
    sub txtFind_Afterupdate()
    If IsNull(txtFind) Then
       Me.FilterOn = False
    Else
      ' Me.Filter = "[ItemName] like '*" & me.txtFind & "*'"
       Me.Filter = "[ItemName] = '" & me.txtFind & "'"
       Me.FilterOn = True
    End If
    end sub
    then open another form using the current record the cursor is on:

    Code:
    sub txtOpen_click()
    docmd.openform "fMyForm",,,"[id]=" & txtID
    end sub

  3. #3
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    371
    How would that solve it ?
    I have complex queries in my form.

  4. #4
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    371
    I read here to set the modal and pop up to true for the second or the pop up form. The one that sometimes open behind.

    https://access-programmers.co.uk/for...d.php?t=200948

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    46,388
    Yes, try popup or modal or open form with acDialog parameter in OpenForm arguments.
    To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window.

  6. #6
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    371
    Can you give me an example of the acDialog parameter ?

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    46,388
    DoCmd.OpenForm "fMyForm", , , "[ID]=" & Me.txtID, , acDialog

    Make Intellisense your friend. It usually provides good guidance when typing VBA.
    To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window.

  8. #8
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    371
    Except mine looks like this:

    Not sure how I can adjust to your way so that the open form doesn’t pop behind the first one.

    DoCmd.OpenForm “secondformName”,,,,,,Trim(searchboxVAL) & ck.

    Ck —- Identify if the check box is check.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    46,388
    That is the OpenArgs argument.

    DoCmd.OpenForm “secondformName”, , , , , acDialog, Trim(searchboxVAL) & ck.

    How did you get those 'smart quotes' in the posted code? Access will not recognize them and code will error.
    To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window.

  10. #10
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    371
    Hi June7

    Thanks for the code example.
    Do you know this line of code will work 99.9% or 100% of the time because when a application is not sound or study is not a good application. I don’t know why a form would pop behind the first form.

    What smart quote are you referring to ?

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    46,388
    The quote characters you show around secondformName, the slanted quotes.
    To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window.

  12. #12
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    371
    June7
    Yes I have those slanted quote but access doesn’t give error.

    I follow your example and I thought it was solved but the pop up second form sometimes still goes behind the main form.

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    46,388
    If you want to provide db for analysis, follow instructions at bottom of my post.
    To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window.

  14. #14
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    371
    Thanks for your advise suggestion. I can try to make a mark up or a replicated DB but I always ended up finding that it is not the same and the issue that occurred can’t be replicated. I would do so if the error can be replicated and I can send off a large database without regards to sensitive information.

    What I ended up doing is I fine tune my sql statements. I previously use two (below is just a simple version)

    Select *
    From a
    Where a.b in (Select * from c)

    The in select is of another query that keep changing in the database.

    Now I just instead do a join and specify the field instead of the asterisk.

    I think this should help if not I am running out of options. What do you advise.

  15. #15
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    46,388
    Sorry, as you noted, since I cannot replicate issue I have no idea why this is happening to you.
    To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Running Queries simultaneously via form
    By ChobeyGuddu in forum Forms
    Replies: 3
    Last Post: 01-25-2017, 04:30 AM
  2. Replies: 2
    Last Post: 03-15-2016, 07:49 AM
  3. Replies: 2
    Last Post: 03-13-2015, 07:34 AM
  4. Running Queries from a form
    By HaYuM in forum Queries
    Replies: 1
    Last Post: 08-23-2013, 02:12 AM
  5. Running multiple queries in form
    By daniejm in forum Forms
    Replies: 3
    Last Post: 01-02-2013, 07:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums