Results 1 to 8 of 8
  1. #1
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398

    Using a modal form

    I can't figure out how to pass the results from a modal form back to the original form.



    Current this form, frm_PC_Log, is working properly. After opening the form, if you click on edit, an input box is displayed for the user to enter a search option. After making the selection, a combo box is displayed. After update of combo23, the record is displayed. This all works correctly.


    I'd like to use the form frm_PC_Log_Search. I've tried commenting out everything related to the input box and the Select Case statements. If I open the form frm_PC_Log_Search, then make the selection, I can't figure out how to update the main form.


    Within the attached DB, the form is working properly.

    Thank you for your assistance!!
    Attached Files Attached Files

  2. #2
    mrojas is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Sep 2013
    Location
    Concord California
    Posts
    72
    I think what you need to do is use the following statement
    DoCmd.OpenForm "frm_PC_log", , , "[FieldNameInFrm_PC_log]= '" & Me.[By Search Type] & '"" ' Assuming field is of text type

  3. #3
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Thank you for the reply.

    A couple of questions: Since frm_PC_log is the form that opened the modal form, it is still open. How do I work your suggestion into that? Also in the original code that works, when combo23 is updated, I have some code that takes place. How do I get that code to run?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    You need to take your form out of modal if you are going to reference a control on another form.

    Me.modal = false
    dosomething here
    Me.modal = True

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by ItsMe View Post
    ...You need to take your form out of modal if you are going to reference a control on another form...
    Sorry, but that's not correct..

    Quote Originally Posted by crowegreg View Post

    ...Since frm_PC_log is the form that opened the modal form, it is still open...
    Since frm_PC_log is Open, you can assign a Value from the Modal Search Form by placing this code in an appropriate event in the Modal Form:


    Forms("frm_PC_log")!F1ControlName = Me.F2ControlName

    or

    Forms!frm_PC_log!F1ControlName = Me.F2ControlName

    where

    F1ControlName is the Control on frm_PC_log that you want the data assigned to

    and

    F2ControlName is the Control on the Modal Form that holds the data to be assigned back to frm_PC_log

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Thanks for the assistance. I'm nearly finished. A slight problem.

    Originally, within form frm_PC_Log, after combo23 was updated, fields are displayed and populated.


    Now, with adding your code to form frm_PC_Log_Search, I've added all the code that was in the event after combo23 updated to got focus combo23.


    Within form frm_PC_Log_Search, I've set the focus to form frm_PC_Log combo23.


    When executing, after going through all the code within got focus combo23, it returns to PC_Log_Search and gives an error of not able to set focus to combo23.


    I've tried commenting out different lines of code, but I get the same results.

    What do you think?
    Attached Files Attached Files

  7. #7
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I figured it out. On the code that I had for afterupdate of comb23, I moved that to a sub, and I call the sub from form frm_PC_Log_Search.

    Thanks again!!

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad you got it working!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Can't cancel the ‘find’ dialog in modal form
    By AndrewAfresh in forum Access
    Replies: 0
    Last Post: 09-23-2011, 11:12 AM
  2. Modal Form Operator
    By mm07nkb in forum Forms
    Replies: 5
    Last Post: 09-01-2011, 10:53 AM
  3. passing variable from modal form to main form
    By crowegreg in forum Forms
    Replies: 2
    Last Post: 06-03-2011, 05:34 PM
  4. Replies: 1
    Last Post: 02-17-2011, 06:23 AM
  5. Replies: 6
    Last Post: 02-10-2011, 09:58 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
  •  
Other Forums: Microsoft Office Forums