Results 1 to 8 of 8
  1. #1
    SoulGame's Avatar
    SoulGame is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    14

    Query from a list in the Form

    Hello, I'm in Micrososft Access 2016 and I have a list on the form.
    I want to filter the field in the list by ID. The filter ID is the form, so I want to access one of the variables inside the form in the SQL statement.

    I have this query now:

    Code:
    SELECT t_parents.CodiParent, t_parents.CodiFamiliaParent, t_parents.CodiTipusFamiliaParten, t_parents.CodiMotiuParent, t_parents.Cognom1, t_parents.Cognom2, t_parents.Nom, t_parents.[nif/nie], t_parents.Origen_Nivell_Renda, t_parents.Sol·licitant, t_parents.Altres_Rendiments
    FROM t_parents
    WHERE (((t_parents.CodiFamiliaParent)=1));


    they filter for a ID static ( ID = 1 )




    But I want to filter by a form ID:
    Click image for larger version. 

Name:	2017_02_13_09_00_05_Access_Consell_Ensenyament_Base_de_datos_C_Users_Usuari_OneDrive_CONSELL.png 
Views:	13 
Size:	30.3 KB 
ID:	27481

    Thanks !!

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    = me.codialu


    Sent from my iPhone using Tapatalk

  3. #3
    SoulGame's Avatar
    SoulGame is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    14
    Quote Originally Posted by andy49 View Post
    = me.codialu


    Sent from my iPhone using Tapatalk

    With this query ask me for the ID when opening the form:


    Click image for larger version. 

Name:	2017-02-13 10_45_53-Access - Consell_Ensenyament _ Base de datos- C__Users_Usuari_OneDrive - CON.png 
Views:	12 
Size:	21.2 KB 
ID:	27482

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Can you use the query builder (design)? It will allow you to put the textbox in as part of the where clause and get the correct syntax


    Sent from my iPhone using Tapatalk

  5. #5
    SoulGame's Avatar
    SoulGame is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    14
    Quote Originally Posted by andy49 View Post
    Can you use the query builder (design)? It will allow you to put the textbox in as part of the where clause and get the correct syntax


    Sent from my iPhone using Tapatalk

    How can I do it? I'll add the list and do not ask me if I want to link it to ID

  6. #6
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    this works fine for me


    WHERE (((t_parents.CodiFamiliaParent)=[Forms]![Formname]![Textboxname]));

  7. #7
    SoulGame's Avatar
    SoulGame is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    14
    Quote Originally Posted by andy49 View Post
    this works fine for me


    WHERE (((t_parents.CodiFamiliaParent)=[Forms]![Formname]![Textboxname]));
    I do not get it. I am proving in many ways and it does not work for me. I tell you the names of the form:


    Name form: AddAlumneDades (serio1)
    List Name: Lista73
    Name field of the table: CodiFamilia


    I have interacted with:

    Code:
    WHERE (((t_parents.CodiFamiliaParent)= me.For[AddAlumneDades(serio1)]
    [Lista73]![CodiFamilia]));


    Is correct?

    Thanks

  8. #8
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    WHERE (((t_parents.CodiFamiliaParent)= Forms![AddAlumneDades (serio1)]!CodiFamilia));

    Then in the AfterUpdate event of CodiFamilia, requery the listbox:
    Me!Lista73.Requery

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

Similar Threads

  1. Replies: 18
    Last Post: 07-06-2015, 10:07 AM
  2. Replies: 1
    Last Post: 04-21-2014, 08:00 AM
  3. Replies: 3
    Last Post: 03-19-2014, 10:40 AM
  4. Make Run Query to open a Form instead of a list
    By damiendellon in forum Queries
    Replies: 3
    Last Post: 01-17-2013, 10:48 PM
  5. list box on a form based on query
    By nykedel in forum Forms
    Replies: 0
    Last Post: 06-15-2010, 01:12 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