Results 1 to 4 of 4
  1. #1
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434

    Set combobox rowsource on piece of query

    hi


    have a form (a continuos one) that has this recordsource

    Code:
    SELECT [LK contatti_messaggi TOT UNICI LOCALE].ID, [LK contatti_messaggi TOT UNICI LOCALE].[Nome cognome], [LK contatti_messaggi TOT UNICI LOCALE].[SENDER PROFILE URL], [LK contatti_messaggi TOT UNICI LOCALE].[CONVERSATION ID], [LK contatti_messaggi TOT UNICI LOCALE].Position, [LK contatti_messaggi TOT UNICI LOCALE].Company, Comuni.Comune, Mercato.Mercato, Settore.Settore, [LK contatti_messaggi TOT UNICI LOCALE].Contratto, [LK contatti_messaggi TOT UNICI LOCALE].[Connesso il], [LK contatti_messaggi TOT UNICI LOCALE].[Connesso Il_2], [LK contatti_messaggi TOT UNICI LOCALE].[Data Invio], [LK contatti_messaggi TOT UNICI LOCALE].SUBJECT, [LK contatti_messaggi TOT UNICI LOCALE].CONTENT, [LK contatti_messaggi TOT UNICI LOCALE].FOLDER, [LK contatti_messaggi TOT UNICI LOCALE].[Da contattare il], [LK contatti_messaggi TOT UNICI LOCALE].[Non interessante], [LK contatti_messaggi TOT UNICI LOCALE].[In db], [LK contatti_messaggi TOT UNICI LOCALE].[Last name] 
    FROM Mercato RIGHT JOIN (Settore RIGHT JOIN (Comuni RIGHT JOIN [LK contatti_messaggi TOT UNICI LOCALE] ON Comuni.IDComune = [LK contatti_messaggi TOT UNICI LOCALE].CittàID) ON Settore.ID = [LK contatti_messaggi TOT UNICI LOCALE].Settore) ON Mercato.ID = [LK contatti_messaggi TOT UNICI LOCALE].Mercato;

    i use another form to filter the first form, i have some comboxes that allow me to select the field i want to filter, and another combobox that gets every value in that field.
    to get every value from a specific field i extract the piece of recordsource after "FROM", and before i put "SELECT DISTINCT" & FIELDNAME; until it is a field not calculated with other tables it is ok, but i've got problems with "mercato" and "settore" that in the "lk contatti_messaggi totali" are numeric values and i get the real value from "mercato" table and "settore" table.

    the rowsource is :
    Code:
    SELECT DISTINCT Mercato FROM Mercato RIGHT JOIN (Settore RIGHT JOIN (Comuni RIGHT JOIN [LK contatti_messaggi TOT UNICI LOCALE] ON Comuni.IDComune = [LK contatti_messaggi TOT UNICI LOCALE].CittàID) ON Settore.ID = [LK contatti_messaggi TOT UNICI LOCALE].Settore) ON Mercato.ID = [LK contatti_messaggi TOT UNICI LOCALE].Mercato;
    i get the error "the specific field "mercato" could be relative to more tables listed in the from clause"

    i can't figure it out
    thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Can't you put the query in the combo,then run it?

  3. #3
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434
    unfortunely not, cause the first combobox select the field, this one select values. Sometime the source is a table, other times is a query, so i made a complex code to manage every situation. I'll try to change some field names to not match table name as suggested in pm
    EDIT if i write "SELECT DISTINCT Mercato.mercato" it works. now the problem is to figure out how to get automaticalli "mercato.mercato" instead of mercato

  4. #4
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    434
    solved, i exctract the complete field name (with table) using this code
    Code:
          Dim StrPc As String      Dim FldVar As String
          StrPc = Left(StrFld, InStr(StrFld, "." & Me.FldFilt) + Len(Me.FldFilt))
          MsgBox (StrPc)
          FldVar = Mid(StrPc, InStrRev(StrPc, " ") + 1) 'Right(StrPc, Len(StrPc) - InStr(StrFld, "." & Me.FldFilt))
          MsgBox (FldVar)
    this code finds the field i select (mercato) in the recordsource, and extracts the piece of text with the table (mercato.mercato)

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

Similar Threads

  1. Set rowsource of combobox
    By diegomarino in forum Access
    Replies: 4
    Last Post: 11-28-2020, 10:16 AM
  2. Combobox filtered rowsource?
    By TerraEarth in forum Access
    Replies: 4
    Last Post: 04-03-2018, 02:28 PM
  3. No Results on Requery for Combobox RowSource
    By dccjr in forum Programming
    Replies: 3
    Last Post: 05-10-2013, 06:08 PM
  4. combobox rowsource per row on a subform
    By kowalski in forum Access
    Replies: 2
    Last Post: 12-05-2012, 01:49 AM
  5. combobox rowsource
    By dirkvw in forum Forms
    Replies: 3
    Last Post: 06-20-2011, 05: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