Results 1 to 4 of 4
  1. #1
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93

    Subform control reference

    Hello everyone,


    Suppose I have a form and on that form I have a subform and on that subform I have one list box and one text box and I need to filter the list box based on the value of the text box. So I have to put a reference to the text box on the criteria of the embedded query of the list box. So how do you write the reference of the text box value ? I did some googling and I came up with this format :

    Forms!MainformName!SubformName!Form!TextBoxName.Te xt

    But it did not work, I keep getting enter parameter popup window when I open the form or run the query. Then I tried this format:

    Forms!SubformName!TextBoxName.Text

    But this only works when I open the subfrom directly from the navigation pane , if I open the main form I get the enter parameter popup window again.
    What is it that I am doing wrong ?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    You dont need the '.text'.
    you did it correctly, Forms!MainformName!SubformName!Form!TextBoxName (no .text needed)
    in the query criteria , always use the BUILDER. It gets the object spelling and path name correct, you just click on it. And yours looks correct.

    Note: In the textbox AFTERUPDATE event, you must refresh the listbox so it can see the change:
    Code:
    sub txtBox_afterupdate()
      listbox.requery
    end sub

  3. #3
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93
    thanks for your replay ranman256,

    I am still getting the enter parameter window even when I removed the text part from the reference, I tried using the expression builder as you have suggested, but in the builder I only get as far as subformName and then I can't find the Text Box control name

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The param window is happening because something is misspelled or no longer exists.
    the builder WILL show every text box.

    If in a query: make sure every field is correct
    if in a report: check the grouping for bad fields

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

Similar Threads

  1. Reference Control on Subform Problem
    By McArthurGDM in forum Queries
    Replies: 1
    Last Post: 02-11-2015, 04:38 PM
  2. Make subform control reference with a string
    By dcdimon in forum Programming
    Replies: 2
    Last Post: 04-01-2014, 02:24 PM
  3. Replies: 3
    Last Post: 10-07-2013, 12:27 PM
  4. Replies: 1
    Last Post: 05-12-2011, 02:25 PM
  5. Can't reference control in subform
    By evanscamman in forum Forms
    Replies: 0
    Last Post: 12-25-2007, 06:47 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