Page 6 of 16 FirstFirst 123456789101112131415 ... LastLast
Results 76 to 90 of 238
  1. #76
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What is that supposed to be/do? You appear to have it in the wrong argument (window mode). OpenArgs is one more comma, wherecondition is earlier:

    http://www.baldyweb.com/wherecondition.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  2. #77
    Etoimos is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Mar 2020
    Posts
    249
    Thanks Paul, that sheds a bit more light on it. I'm trying to do basically what you linked to, but I need to narrow the record selection down using my three combo boxes for Event, Date, and Run number. So something like this?

    Code:
    DoCmd.OpenForm "Run Sheet", , , "Event = '" & Me.EventLookupCombo
    & "'"
    But I need to add a
    Code:
     
    "ExecutionDate = '" & Me.DateLookupCombo
    & "'"
    and
    Code:
     
    "RunNumber = '" & Me.RunLookupCombo & "'"

  3. #78
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Concatenate " AND " between each condition.

    Code:
    "Event = '" & Me.EventLookupCombo & "' AND SecondField = '"...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #79
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    In your RunResultData you have and ID as the primary key. I suspect that what you are trying to do is use your three cascading combo boxes to isolate one specific record you are trying to open/view. So in that case the last combo box should not return a "run number" but the actual ID of the record. That is easily achieved if you bind the combo to the ID, set its column count to 2 (or more as needed) and set the width of the first column to 0. So the RowSource of the RunLookupCombo would be something like this: SELECT DISTINCT ID, RunNumber FROM RunResultsDate WHERE...the conditions for the preceding two combos. What I am trying to say is that you only need to pass an ID to the openform WhereCondition:
    Code:
    DoCmd.OpenForm "Run Sheet", , , "[ID]= " & Me.RunLookupCombo
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #80
    Join Date
    Apr 2017
    Posts
    1,681
    You can do this with single combo. Have the RowSource for EventLookupCombo like
    Code:
    SELECT rrd.ID, Left(e.Event & Space(20),20) & ": " & Format(er.ExecutionDate,"yyyymmdd") & ": " & CStr(er.RunNumber) FROM 
    (Events e INNER JOIN EventRun er ON e.EventID = er.EventID) INNER JOIN RunResultsDate rrd ON rrd.ID = er.EventRunID
    ORDER BY 2 ASC
    Set ColumnCout = 2, BoundColumn = 1, ColumnWidths = "0,2.5" for EventLookupCombo.

    Combo's selection list is ordered alphabetically. To avoid the list order to be scrambled, all column entries except the last column must be of same width (in my example 20 characters, 8 characters, and whatever). When you select the combo, and start type the event name, the 1st possible selection starting with entered string is activated.
    Code:
    DoCmd.OpenForm "Run Sheet", , , "[ID]= " & Me.RunLookupCombo

  6. #81
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    @ ArviLaanemets: Please have a look at posts # 69,70,71

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #82
    Etoimos is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Mar 2020
    Posts
    249
    Quote Originally Posted by pbaldy View Post
    Concatenate " AND " between each condition.

    Code:
    "Event = '" & Me.EventLookupCombo & "' AND SecondField = '"...
    I tried adding this code to the On Click for my button:

    Code:
    DoCmd.OpenForm "Run Sheet", , , "Event = '" & Me.EventLookupCombo & "' AND ExecutionDate = '" & Me.DateLookupCombo & "' AND RunNumber = '" & Me.RunLookupCombo & "'"
    That will open my Run Sheet form, but it is a blank form with none of the data displayed.

  8. #83
    Etoimos is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Mar 2020
    Posts
    249
    Quote Originally Posted by Gicu View Post
    In your RunResultData you have and ID as the primary key. I suspect that what you are trying to do is use your three cascading combo boxes to isolate one specific record you are trying to open/view. So in that case the last combo box should not return a "run number" but the actual ID of the record. That is easily achieved if you bind the combo to the ID, set its column count to 2 (or more as needed) and set the width of the first column to 0. So the RowSource of the RunLookupCombo would be something like this: SELECT DISTINCT ID, RunNumber FROM RunResultsDate WHERE...the conditions for the preceding two combos. What I am trying to say is that you only need to pass an ID to the openform WhereCondition:
    Code:
    DoCmd.OpenForm "Run Sheet", , , "[ID]= " & Me.RunLookupCombo
    Cheers,
    I played around with this and it broke my combo boxes. I'm going to mess with it some more and see if I screwed something else up.

  9. #84
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    In your concatenation you treat all as text with the wrapping in single quotes. For dates use # and nothing is needed for numbers:
    DoCmd.OpenForm "Run Sheet", , , "Event = '" & Me.EventLookupCombo & "' AND ExecutionDate =#'" & Me.DateLookupCombo & "# AND RunNumber = " & Me.RunLookupCombo & ""

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  10. #85
    Etoimos is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Mar 2020
    Posts
    249
    I had the # for the date, but it was still messing up. Maybe it was the single quote for the number in the last part that was hosing it. Thanks.

  11. #86
    Etoimos is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Mar 2020
    Posts
    249
    Does the red single quote in this code need to be removed with the # sign is added?

    Code:
    DoCmd.OpenForm "Run Sheet", , , "Event = '" & Me.EventLookupCombo  & "' AND ExecutionDate =#'" & Me.DateLookupCombo & "# AND  RunNumber = " & Me.RunLookupCombo & ""

  12. #87
    Etoimos is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Mar 2020
    Posts
    249
    I did remove that extra single quote and the Run Sheet form still opens up with no data in it.

  13. #88
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Can you put a break in code on the line and inspect the values of the three combos? Are the combos related (cascading) or are they independent of each other? If latest are you sure there is a record that satisfies all three? And I also remember that your form opens by default in DataAdd mode meaning it will be blank because is at a new record, so you need to change the mode in the OpenForm.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  14. #89
    Etoimos is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Mar 2020
    Posts
    249
    Quote Originally Posted by Gicu View Post
    Can you put a break in code on the line and inspect the values of the three combos? Are the combos related (cascading) or are they independent of each other? If latest are you sure there is a record that satisfies all three? And I also remember that your form opens by default in DataAdd mode meaning it will be blank because is at a new record, so you need to change the mode in the OpenForm.

    Cheers,
    They are cascading and they do filter down to an actual record. I just tried adding the ReadOnly code and I don't think I have it in the right spot. This is the code I used:

    Code:
    DoCmd.OpenForm "Run Sheet", , , acFormReadOnly, "Event = '" & Me.EventLookupCombo & "' AND ExecutionDate = #" & Me.DateLookupCombo & "# AND RunNumber = " & Me.RunLookupCombo & ""

  15. #90
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    The DataMode argument goes after the WhereCondition:https://docs.microsoft.com/en-us/off...docmd.openform
    Code:
    DoCmd.OpenForm "Run Sheet", , , "Event = '" & Me.EventLookupCombo & "' AND ExecutionDate = #" & Me.DateLookupCombo & "# AND RunNumber = " & Me.RunLookupCombo & "",acFormReadOnly
    But it would be much easier if the last combo would return the unique record ID instead of the run number, you would only have to reference one control.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 4
    Last Post: 10-13-2014, 09:20 AM
  2. Replies: 6
    Last Post: 02-19-2014, 11:11 AM
  3. Replies: 3
    Last Post: 07-03-2013, 10:38 AM
  4. Replies: 1
    Last Post: 10-30-2012, 10:29 AM
  5. Replies: 1
    Last Post: 07-11-2012, 08:36 AM

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