Results 1 to 2 of 2
  1. #1
    jeffr27 is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    May 2011
    Posts
    3

    append query: dlookup or dmax problem

    Hello all! I'm having a problem with an append query that appends to 2 different tables with one click of a button. My tables are:

    tblReview(ReviewID-autonum, CC, etc..., DateAdded)
    tblRecoup(RecoupID-autonum, ReviewID, CC, etc...)

    The first part of the code enters the info from a form into tblReviews - obviously it creates a random number for ReviewID and DateAdded = now().

    The second part of the code takes different info from the same form and saves it into tblRecoup. However, tblRecoup.ReviewID should be the same as tblReview.ReviewID, but I cannot reproduce the result.

    The code I'm using is:


    Code:
    strSQL = "INSERT INTO tblRecoupments ([ReviewID], [CC], etc...) " & _
    "VALUES (" & DLookup("ReviewID", "tblReviews", DMax("DateAdded", "tblReviews", "tblReviews.CC = Forms!frmCCReview!cboCC")) & ", etc...
    What I hoped the code would do is retrieve the ReviewID(an autonumber) in tblReviews with the most recent date where CC=user entered form. All of the fields save their information accurately, with the exception of ReviewID in tblRecoup, which always saves the ReviewID as 1 instead of whatever the first part of the code assigned the autonumber as, and I don't know why.

    Any help is appreciated! Thanks, -J

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    The way I approach this is to make a plain ole Select query of tblReview that results in the record just appended. It serves a very useful sanity check that I have found/isolated the correct record. Save that query with a name.

    Then one must be able to join this query into the 2nd Append Query - and will of course provide that ID value that you want.

    Hope this helps.

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

Similar Threads

  1. Dlookup Problem in Access 2007
    By doquan0 in forum Programming
    Replies: 1
    Last Post: 08-27-2010, 05:41 AM
  2. Newbie Dlookup problem
    By opopanax666 in forum Programming
    Replies: 7
    Last Post: 08-13-2010, 05:47 AM
  3. dlookup function problem
    By bdaniel in forum Programming
    Replies: 3
    Last Post: 04-26-2010, 05:55 AM
  4. Dlookup problem
    By CalifDan in forum Reports
    Replies: 4
    Last Post: 12-09-2009, 06:09 AM
  5. I have Problem in processing Dlookup Function
    By Katada in forum Programming
    Replies: 2
    Last Post: 04-23-2006, 12:07 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