Results 1 to 10 of 10
  1. #1
    aceoftrades is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    35

    Subform not working

    I have a form that works perfectly as a stand alone form. I filter records and then select the one I want to open in a new form. The code is:
    Private Sub Option64_Click()
    Dim sWHERE As String


    'Comment out or delete the line that does not apply --
    ''If the ID is a number, built the WHERE clause like this:
    sWHERE = "[CustomerID] = " & Me.CustomerID



    'Open the form
    DoCmd.OpenForm "CustomerF", acNormal, , sWHERE


    End Sub

    When I put this form into another form as a subform it no longer works.
    I think I have to change the sWhere but not sure to what??? The form is frmMain and the subform is frmCustomer.
    Thank you in advance for any help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    You say forms are frmMain and frmCustomer, what is "CustomerF"?

    Be specific in your info. What form works until you make it a subform? Which form has code to open which form?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    aceoftrades is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    35
    frmCustomer has the code listed above... It works perfect opening CustomerF form to the selected Customer when it is not included as a subform ... just a form..

    When I ad frmCustomer to frmMain as a subform it does not open the CustomerF form when the Customer is selected.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Presume frmCustomer is Single View and button is still on frmCustomer and CustomerF is a stand alone form and CustomerID is in the RecordSource of frmCustomer.

    Are you getting error message or just nothing happens?

    Do you want to provide project for analysis?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    aceoftrades is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    35
    Here is the file.

    Open frmCustomerSearch and select a Customer by clicking on the radio button on the left of the name...It will open CustomerF for that particular Customer record.
    Then open Main. frmCustomerSearch is a subform of Main. If you click on the same radio button nothing happens. No error message.
    I'm pretty sure I need to change the code:
    sWHERE = "[CustomerID] = " & Me.CustomerID

    once I insert it as a subform to something but I'm not sure what.


    Thanks for looking.
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    It's because Main form is set as Popup. Nothing else can open on top of it.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    aceoftrades is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    35
    Wow...that sucks! Any suggestions on what to do? I'm using popups so that the form opens to full screen. Is there a way to set it to close the frmCustomerSearch and open CustomerF as a popup?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Yes, set a variable to the CustomerID. Close frmCustomerSearch. Open CustomerF with the variable as parameter instead of reference to the control on frmCustomerSearch because it is already closed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    aceoftrades is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    35
    Thanks...Could you be a little more specific...I'm new to access and trying to grasp what you are saying but can't...

    Also, If you would recommend another way other than popup I would be interested in hearing that. I just don't want the user able to access the database other than the forms. Thanks

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    I use project settings to disable the ribbon, navigation pane, and shortcut menu. Although can override these settings by holding down shift key when project opens, my users don't know that and even if they did, I trust they won't use it (we are a small work group). I only use popup setting on forms that require a single quick input from user, such as a date or a document number, not on my main data entry forms.

    You already have the variable in your code. Modify like:

    Private Sub Option64_Click()
    Dim sWHERE As String
    sWHERE = "[CustomerID] = " & Me.CustomerID
    DoCmd.Close acForm, Me.Name, acSaveNo
    DoCmd.OpenForm "CustomerF", acNormal, , sWHERE
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 5
    Last Post: 03-17-2011, 06:21 AM
  2. Audit trail not working on form with subform
    By jpkeller55 in forum Access
    Replies: 52
    Last Post: 01-07-2011, 12:39 PM
  3. OpenForm in subform not working
    By eyuen in forum Forms
    Replies: 3
    Last Post: 11-10-2010, 12:03 PM
  4. Filter command not working for subform
    By yes sir in forum Access
    Replies: 15
    Last Post: 10-15-2010, 10:06 PM
  5. Replies: 1
    Last Post: 09-28-2009, 05:21 PM

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