Need help with an access max/dlookup

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
194
Office Version
  1. 365
Platform
  1. Windows
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:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
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
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top