Results 1 to 8 of 8
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    VBA dlookup but with where

    BookingMinimum = DLookup("MinimumAudience", "tblJncShowYear", "ShowsID=" & ShowsID)



    I have a problem with this because once the show is selected - it picks the first value from the junction and not on the condition of the year selected.

    i.e. selected year 2012

    cascading combobox select show according to year

    I need to import the price/minimum audience according to the show and the year the show is in....

    It pulls in the wrong price/minimum audience at the moment. (I think it just pulls in the first year even if it is the second).

    so I need it shows ID but also the year it is tied to.

  2. #2
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Do I just use an AND in the criteria?

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    ShowPricePerStudent = DLookup("ShowCostTotal", "tblJncShowYear", "ShowsID=" & ShowsID And "ShowYearID=" & Me.BookingYear)

    but I get a type missmatch....

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    ShowPricePerStudent = DLookup("ShowCostTotal", "tblJncShowYear", "ShowsID=" & Me.ShowsID & " AND ShowYearID=" & Me.BookingYear)

    works

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Slight change needed.....
    If "Me.BookingYear" is a number, try:
    Code:
    ShowPricePerStudent = DLookup("ShowCostTotal", "tblJncShowYear", "ShowsID = " & ShowsID & " And ShowYearID = " & Me.BookingYear)

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by ssanfu View Post
    Slight change needed.....
    If "Me.BookingYear" is a number, try:
    Code:
    ShowPricePerStudent = DLookup("ShowCostTotal", "tblJncShowYear", "ShowsID = " & ShowsID & " And ShowYearID = " & Me.BookingYear)
    Thanks but curious, what exactly is the change compared to my previous post? I'm not being sarcastic I'm very worried now

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Not a thing.
    You solved it just before I posted the same thing.

  8. #8
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by ssanfu View Post
    Not a thing.
    You solved it just before I posted the same thing.
    oh phew

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

Similar Threads

  1. Dlookup
    By imtiaz703 in forum Forms
    Replies: 1
    Last Post: 03-20-2012, 11:03 AM
  2. Dlookup
    By Wombat in forum Forms
    Replies: 2
    Last Post: 03-03-2012, 07:21 PM
  3. DlookUp
    By cap.zadi in forum Forms
    Replies: 5
    Last Post: 09-21-2011, 07:16 PM
  4. DLookup
    By smidgey in forum Forms
    Replies: 13
    Last Post: 01-19-2011, 09:27 AM
  5. DLookup Help
    By Alex Motilal in forum Queries
    Replies: 3
    Last Post: 01-17-2011, 02:01 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