Results 1 to 2 of 2

Thread: Need help with an access max/dlookup

  1. #1
    Board Regular
    Join Date
    Feb 2019
    Posts
    138
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Need help with an access max/dlookup

    Hi Everyone,

    I'm an absolute novice at best with Access but am trying to learn.

    I am running the code below on a button in a filtered form. What I would like to do is run it after my last field is entered IN THE FIRST RECORD and I press the ENTER key
    creating a new record. In addition in the SLOT field of the first record we I enter "1". What I would like it to do is in the 2nd record, be 2, third record 3, etc.

    Thanks a bunch!!

    Code:
    Dim ID As Long
    ID = DMax("ProductID", "Table1")
    DoCmd.GoToRecord , , acNewRec
    Slot = DLookup("Slot", "Table1", "ProductID=" & ID)
    Associate = DLookup("Associate", "Table1", "ProductID=" & ID)
    DateEntered = DLookup("DateEntered", "Table1", "ProductID=" & ID)
    Scan.SetFocus
    Last edited by Buns1976; Feb 15th, 2019 at 03:09 PM.

  2. #2
    Board Regular ranman256's Avatar
    Join Date
    Jun 2014
    Location
    Kentucky
    Posts
    1,775
    Post Thanks / Like
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need help with an access max/dlookup

    just show all records, then filter them all at once.
    No dlookups needed:

    Code:
    '----------------
    sub btnFilter_click()
    '----------------
    dim sWhere as string 
    sWhere = "1=1"
    if not IsNUll(cboST) then sWhere = sWhere & " and [State]='" & cboST & "'"
    if not IsNUll(cboCity) then sWhere = sWhere & " and [city]='" & cboCity & "'"
    if not IsNUll(cboZip) then sWhere = sWhere & " and [ZipCode]='" & cboZip & "'"
    If sWhere = "1=1" Then
      Me.FilterOn = False
    Else
      Me.Filter = sWhere
      Me.FilterOn = True
    End If
    end sub

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •