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

    Problem on setting source in continuos form

    hi,


    i have a continuos form called "composition" with recordsource is based on this
    Code:
       Me.RecordSource = "SELECT [DB 1T ptf banca taglio clienti].TrattativaID, [DB 1T ptf banca taglio clienti].CandidatoID, [DB 1T ptf banca taglio clienti].[Taglio cliente], Count([DB 1T ptf banca taglio clienti].[Taglio cliente]) AS [ConteggioDiTaglio cliente], Switch([taglio cliente]=""<100k"",1,[taglio cliente]=""100k-300k"",2,[taglio cliente]=""300k-500k"",3,[taglio cliente]=""500k-700k"",4,[taglio cliente]=""700k-1mln"",5,[taglio cliente]=""1mln-2mln"",6,[taglio cliente]=""2mln-5mln"",7,[taglio cliente]=""5mln-10mln"",8,[taglio cliente]="">=10mln"",9) AS Ordinamento " & vbCrLf & _   "FROM [DB 1T ptf banca taglio clienti] " & vbCrLf & _
       "GROUP BY [DB 1T ptf banca taglio clienti].TrattativaID, [DB 1T ptf banca taglio clienti].CandidatoID, [DB 1T ptf banca taglio clienti].[Taglio cliente], Switch([taglio cliente]=""<100k"",1,[taglio cliente]=""100k-300k"",2,[taglio cliente]=""300k-500k"",3,[taglio cliente]=""500k-700k"",4,[taglio cliente]=""700k-1mln"",5,[taglio cliente]=""1mln-2mln"",6,[taglio cliente]=""2mln-5mln"",7,[taglio cliente]=""5mln-10mln"",8,[taglio cliente]="">=10mln"",9) " & vbCrLf & _
       "HAVING ((([DB 1T ptf banca taglio clienti].TrattativaID)=[Maschere]![home].[sottomascheraspostamento2]![sottomascheraspostamento1].[form]![CCSceltaTrattativa])) " & vbCrLf & _
       "ORDER BY Switch([taglio cliente]=""<100k"",1,[taglio cliente]=""100k-300k"",2,[taglio cliente]=""300k-500k"",3,[taglio cliente]=""500k-700k"",4,[taglio cliente]=""700k-1mln"",5,[taglio cliente]=""1mln-2mln"",6,[taglio cliente]=""2mln-5mln"",7,[taglio cliente]=""5mln-10mln"",8,[taglio cliente]="">=10mln"",9);"
    works fine, it is on "on load" event, so when i load my form i see data as it should

    as you can see i have a criteria based on "[Maschere]![home].[sottomascheraspostamento2]![sottomascheraspostamento1].[form]![CCSceltaTrattativa]" (maschere! is forms!). the control is in multi level navigation forms.
    now, i want to change this criteria in a simple " & me.openargs & ", cause i can open the main form either through the navigation form that the form directly.

    so i just overwrite "[Maschere]![home].[sottomascheraspostamento2]![sottomascheraspostamento1].[form]![CCSceltaTrattativa]" and i put " & me.openargs & ", sometimes it works sometimes not

    the problem specifically is when i open not the form "composition", but when i open another form that contains this "composition" form, i have an error of too much ")" in closing the criteria
    i'm guessing how i have to write the criteria

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    Are you still using OpenArgs when the form is a subform? If so you can try

    Me.Parent.OpenArgs

    Or test for OpenArgs being null and using the form reference if it is.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    409
    man, it was precisely as you said. I'm just learning now and i'm being addicted to this forum

    thanks very much

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    409
    however, is there any way to check if the form is a form or a subform in another form? sometimes i open this form as indipendent form

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    I'm not at a computer right now. Check out IsLoaded. You can use it with the form's name. If it doesn't show as loaded, it's a subform.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    409
    good, i've found that there is "isSubform" too

  8. #8
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    Ah, good job. I haven't needed it, good to know it exists.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. continuos form not more refreshing
    By diegomarino in forum Access
    Replies: 7
    Last Post: 05-05-2020, 09:52 AM
  2. filters in continuos form using VBA code
    By TriFith in forum Access
    Replies: 5
    Last Post: 01-11-2017, 04:48 AM
  3. Replies: 1
    Last Post: 03-27-2015, 09:31 PM
  4. Sum textbox in continuos form
    By cuongmyh in forum Forms
    Replies: 2
    Last Post: 02-27-2015, 10:12 AM
  5. Form with Subreport and setting record source.
    By Monterey_Manzer in forum Forms
    Replies: 3
    Last Post: 02-14-2013, 05:14 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