Results 1 to 5 of 5
  1. #1
    shane201980 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    25

    Command Button not working on Subform inside Navigation Subform

    Ok, please bare with me as this may be difficult to explain.



    I've created my forms and placed several forms as subforms, and then placed these forms on Navigation Form (I need the tab effects). My problem is that I've been trying to code a command button that is located on a subform that is stored on the Navigation Form. I've done so much re-coding that i can only provide the latest.

    Forms and hierarchy:

    formNameList ------\
    formNameCard------\ -------(These forms become subforms of)---formContactCard---(This becomes a subform of the Navigation Form)---formMain

    So above is the layout of the forms and how they are placed as subforms. So now for the problem: I have a command button on the formNameCard to open a separate form called "formEditComments" and filter based on ID(the Primary Key), which I have had working on the form itself. Now when I open the formMain where all work will happen, this button does not work, it asks for the Perimeter Value of "formNameCard". I need to pass the value held in the subform when opening the new form, but I believe I'm several forms deep and having trouble getting there. Since I am currently working in Macros (Not by choice), this is the Where Condition that I currently have:


    [tblComments]![Contact ID]=[Forms]![formMain].[Controls]![NavigationSubform].[Form].[Controls]![txtContactID]
    (What I have done is I added an unbound text box to the "formContactCard" which inherits it's value from the subform; in an effort to shortcut to the value needed to carry to the new form)

    This is where i was at before:

    [tblComments]![Contact ID]=[Forms]![formMain].[Controls]![NavigationSubform].[Form].[Controls]![formNameCard].[Form]
    (Here I was trying to get down to the textbox which holds the ID for the contact, but unfortunately the system stopped giving me options to go any further.)

    FYI - I am not using any "Link Master Fields" or "Link Child Fields" due to the fact that my subforms "formNameList" and "formNameCard" stop passing values back and forth and I can no longer show my continuous list of contacts and select each one as I want. So i don't know if this is having some effect here, but i need to do this without this feature, or so i believe.

    Thanks in advance!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I never use navigation form, I use tab control. Couple times I worked with poster's db with navigation form, think had same difficulty trying to reference controls. Don't remember if ever figured it out.

    Is this a web db?
    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
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    The might be an easier way, using variables global to the Mainform module.

    In the declarations section of the FormMain code module, put this:

    Public ContactID as Integer (or whatever type you need)

    As long as FormMain is open, you can refer to that variable as Forms!FormMain.ContactId.

    Now, in the subform that selects the contact you can have Forms!FormMain.ContactId = [contactField], where [contactfield] is the control containing the Contact_ID on the subform, and the statement in your original question becomes:

    [tblComments]![Contact ID] = Forms!FormMain.ContactId

    and it should work fine.

    If not, please post the code that does not work.

    John

  4. #4
    shane201980 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    25
    June7,

    It's not a web database, I just like the functionality and display of the navigation form. Although it seems a pain for some items to function properly.

    John,

    Ok, so I think this could work. I was doing a little reading on global variables and it sounds like what I need. But I'm a novice and I'm having a little trouble setting the information you posted correctly. Here's what i did:

    1. On "formMain" I placed Public ContactID as Integer at the top near the Options areas before any code. (Integer is fine since this is the Primary Key that's being passed on.)
    2. This is where i think I screwed up. I went to the subform, actually I went directly to the original form, and placed at the top near Options area Forms!FormMain.ContactId = [txtID].

    Now, when I open "formMain" it asks for the Perimeter Value for "ID" (Primary Key) and then it asks for the Perimeter Value for "txtID". I'm not sure what exactly is happening here, possible bad placement.

    I thought I'd through a curve ball in here too. The subform that i am working working with will change ID based on selections from another list subform in the same main form. As long as the public/global variable can change based on this, there shouldn't be any problems.

    Thinking outside the box here - The list subform that is passing ID to the other subform where I'm trying to fix the command button passes a selected value through "browse to" in a Macros function. Is it possible to pass the ID value from the subform to the main form with a similar "browse to" function in a On Current Event? I may be way off base with that one.

    Thanks,

  5. #5
    shane201980 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    25
    UPDATE:

    Ok, so I managed to pass the ID value to the main form, and it updates as soon as the subform updates. I figure at this point everything should be smooth sailing since I no longer have to direct my expressions to the subform..... wrong.

    So I've been going through eveything now and I just realized that the form I'm opening is referenceing back to the original form and not the subform. I'm such an idiot! So my problem is not passing the information, but making sure that all forms and Controls are reading from the subform that is open and not the original form that is technically closed.

    Thanks again guys for your time and knowledge.

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

Similar Threads

  1. Command button to populate subform
    By akhlaq768 in forum Forms
    Replies: 2
    Last Post: 02-07-2012, 04:57 AM
  2. Command Button Problem is Subform
    By Lupson2011 in forum Access
    Replies: 3
    Last Post: 08-25-2011, 08:39 AM
  3. Replies: 10
    Last Post: 12-31-2010, 12:35 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. Open a linked subform with a command button
    By flablueeyedblond in forum Forms
    Replies: 0
    Last Post: 11-18-2005, 01:18 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