Results 1 to 3 of 3
  1. #1
    Fish218 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    68

    DLookup issues...

    I'm having issues trying to get this code to work. It's supposed to take the number "CountofIndividualFish" in "qry2012" with the criteria1 = [Text161] (which is a text box with control source =Right([Set_Date],4) AND [CollectorID] which is a combo box on the form the user selects before they enter the Set_Date.

    Private Sub Set_Date_AfterUpdate()
    [Text159].Value = DLookup("CountofIndividualFish", "qry2012", "CollectionYear=" & Forms!frmCommercial2!Form1!Text161 & "AND CollectorID=" & Forms!frmCommercial2!Form!CollectorID)


    End Sub

    Any help would be GREATLY appreciated...

    -Fish

  2. #2
    Fish218 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    68
    So I shortened the code per instructions on another forum:

    Dim varYear As Integer
    Dim varCollector As Integer
    varYear = "Forms![frmCommercial2]![Form1].Form![Text161]"
    varCollector = "Forms![frmCommercial2]![Form1].Form![CollectorID]"
    [Text159] = DLookup("[IndividualFishID]", "qry2012", "[CollectionYear]="& varYear And "[CollectorID]=" & varCollector")
    End Sub

    But I'm still having issues with the DLookup command. What's the deal?

  3. #3
    Fish218 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    68
    Solved it on my own...

    Private Sub Set_Date_AfterUpdate()

    Dim varYear As Integer
    Dim varCollector As Integer

    varYear = [Forms]![frmCommercial2]![Form1]![Text161]
    varCollector = [Forms]![frmCommercial2]![Form1]![CollectorID]

    [Text159] = DLookup("[CountofIndividualFishID]", "qry2012", "[CollectionYear]=" & varYear & " And [CollectorID]=" & varCollector)
    End Sub

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

Similar Threads

  1. Query issues
    By admessing in forum Queries
    Replies: 25
    Last Post: 12-27-2011, 11:23 AM
  2. Query Issues
    By Dale in forum Access
    Replies: 1
    Last Post: 11-29-2011, 01:35 AM
  3. Expression issues
    By doomy304 in forum Forms
    Replies: 5
    Last Post: 07-02-2011, 01:17 PM
  4. issues with DSum
    By ozdemirozgur in forum Access
    Replies: 3
    Last Post: 05-08-2011, 02:48 PM
  5. printing issues
    By dmmartin in forum Programming
    Replies: 2
    Last Post: 05-29-2009, 08:22 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