Results 1 to 6 of 6
  1. #1
    WSpivak is offline Novice
    Windows 11 Office 365
    Join Date
    Jun 2023
    Posts
    3

    Command Button, Variable, Dlookup is it possible?

    I have a table "School" with Schl_no and Schl_name.
    I have a table "Exam" with School which joins on Schl_no

    On Form "SearchQuery" I have a command button that looks up School, Student_name and Course, which returns the correct answers.

    My client says her staff doesn't really know the school numbers, but the names (some of which are quite long).

    Is there a way to do a DLookup (or other lookup) with the given school name (or abbrevaitoin) and return all possible records for school and then cull based on the other criteria?

    I have been unsccessful with DLookup:

    Dim S As String
    Dim S1 As String
    S1 = InputBox("Enter School Number", "School", "*")


    S = DLookup("[Schl_no]", "School", "[Schl_name] ='" & "*" & S1 & "*" & "'")
    S1 returns the proper value from the dialogue box
    S returns null

    Thanks

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Use a combo to select the school name (no typos invoved then) and get the school number from an additional column.
    You are asking for school number yet are using it as school name?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Google "Cascading combo boxes"
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  4. #4
    WSpivak is offline Novice
    Windows 11 Office 365
    Join Date
    Jun 2023
    Posts
    3
    Thanks for you help... didn't do what I wanted, but found a simple workaround that suffices until I have more time to devote to solving the issue.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by WSpivak View Post
    Thanks for you help... didn't do what I wanted, but found a simple workaround that suffices until I have more time to devote to solving the issue.
    Care to share?
    These forums are here to help other people after all?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    WSpivak is offline Novice
    Windows 11 Office 365
    Join Date
    Jun 2023
    Posts
    3
    I just put a standalone combo box, so they can just find the datapoint. Nothing brilliant, but it lets them move forward...

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

Similar Threads

  1. Replies: 3
    Last Post: 03-29-2015, 07:42 PM
  2. Replies: 1
    Last Post: 09-12-2014, 06:09 AM
  3. Replies: 3
    Last Post: 08-04-2013, 07:11 AM
  4. Use a variable in a DLOOKUP?
    By leftylee in forum Forms
    Replies: 9
    Last Post: 07-27-2011, 02:00 PM
  5. Replies: 1
    Last Post: 07-27-2010, 02:27 PM

Tags for this Thread

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