DMAX Criteria

  • Thread starter Thread starter David
  • Start date Start date
D

David

I have a table "tblLED" that has a field "LedNumber" that
is incremented automatically, not by autonumber however.
The field starts at 1 and increments based on individual
additions to that particular record. A new record with a
different key needs to start at 1 also.

I am trying to look into the table and search for the max
number for a particular ledger entry to be able to add
entries after the last entry.

My VBA code:

HoldLed = dmax("LedNumber", "tblLED",_
"pLedNumber = forms!frmPU!pledNumber")

All I get as a result is the largest number in the entire
domain, not from my "where" criteria. What am I doing
wrong?.
 
David said:
I have a table "tblLED" that has a field "LedNumber" that
is incremented automatically, not by autonumber however.
The field starts at 1 and increments based on individual
additions to that particular record. A new record with a
different key needs to start at 1 also.

I am trying to look into the table and search for the max
number for a particular ledger entry to be able to add
entries after the last entry.

My VBA code:

HoldLed = dmax("LedNumber", "tblLED",_
"pLedNumber = forms!frmPU!pledNumber")

All I get as a result is the largest number in the entire
domain, not from my "where" criteria. What am I doing
wrong?.

Correct VBA syntax:

HoldLed = dmax("LedNumber", "tblLED", "pLedNumber = " & _
forms!frmPU!pledNumber & ")"


MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
 
David said:
I have a table "tblLED" that has a field "LedNumber" that
is incremented automatically, not by autonumber however.
The field starts at 1 and increments based on individual
additions to that particular record. A new record with a
different key needs to start at 1 also.

I am trying to look into the table and search for the max
number for a particular ledger entry to be able to add
entries after the last entry.

My VBA code:

HoldLed = dmax("LedNumber", "tblLED",_
"pLedNumber = forms!frmPU!pledNumber")


You need to use the value of the field, not a string
containing its reference.

HoldLed = dmax("LedNumber", "tblLED",_
"pLedNumber = " & forms!frmPU!pledNumber)
 
Not sure if this is the problem, but I found this when I
read the online help for DMAX function.
**********************************************************
You can use the DMin or DMax function in a module or macro
or in a calculated control on a form if the field that you
need to display is not in the record source on which your
form is based.
**********************************************************
 
I always use the cstr() function on my numeric controls
when building criteria. Use the "&" to concatenate the
criteria string. You need to convert the numeric to
string.
 
Back
Top