DMax

A

Anne

help! Somehow my DMaxer is not!

My code is Me!MaxNum = DMax
("CRInvNum", "tbl4Receipt", "[InvNum]=[cboInvNum]")

InvNum is my invoice number.

cboInvNum is the combo box selecting the invoice to make
a payment for.

CRInvNum is a unique payment number field, double, two
decimals, derived from InvNum with decimal representing
payment interations.

Example: invoice 12345; first payment CRInvNum is
12345.01; second payment is 12345.02, etc.

The counter works and writes the file correctly. But the
code is not returning 12345.02, rather its returning
12345.01.

What can be done to ensure the highest -- 12345.02 -- is
returned?

Thanks.
 
F

Fredg

Try it this way.
(note the position of the last quote mark.)

Me!MaxNum = DMax ("CRInvNum", "tbl4Receipt", "[InvNum]= " & [cboInvNum])
 
A

Anne

Thanks for trying, but that didn't help. Performs as
before, not returning maximum decimal.

Other ideas?

Thanks,
Anne

-----Original Message-----
Try it this way.
(note the position of the last quote mark.)

Me!MaxNum = DMax ("CRInvNum", "tbl4Receipt", "[InvNum] = " & [cboInvNum])

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Anne said:
help! Somehow my DMaxer is not!

My code is Me!MaxNum = DMax
("CRInvNum", "tbl4Receipt", "[InvNum]=[cboInvNum]")

InvNum is my invoice number.

cboInvNum is the combo box selecting the invoice to make
a payment for.

CRInvNum is a unique payment number field, double, two
decimals, derived from InvNum with decimal representing
payment interations.

Example: invoice 12345; first payment CRInvNum is
12345.01; second payment is 12345.02, etc.

The counter works and writes the file correctly. But the
code is not returning 12345.02, rather its returning
12345.01.

What can be done to ensure the highest -- 12345.02 -- is
returned?

Thanks.


.
 
D

damien

Ann,

personally, I don't like the Domain Aggregate function
(DMax, DLookup etc) so I'd use a Recordset:

Dim rst AS DAO.Recordset 'or ADODB.Recordset if you're
modern !

Set rst = currentdb.OpenRecordset("SELECT MAX(CRInvNum)
FROM tbl4Receipt WHERE InvNum = " & cboInvNum)

Me!MaxNum = rst(0)

rst.Close
Set rst = Nothing

Give it a try anyway and let me know how you get on !


damien
 
A

Anne

Thanks, Damien, but that still does not return
correctly. It gives me 12345.01, when there exists
12345.02 as well.

Other ideas?

Thanks,
Anne
-----Original Message-----
Ann,

personally, I don't like the Domain Aggregate function
(DMax, DLookup etc) so I'd use a Recordset:

Dim rst AS DAO.Recordset 'or ADODB.Recordset if you're
modern !

Set rst = currentdb.OpenRecordset("SELECT MAX(CRInvNum)
FROM tbl4Receipt WHERE InvNum = " & cboInvNum)

Me!MaxNum = rst(0)

rst.Close
Set rst = Nothing

Give it a try anyway and let me know how you get on !


damien
-----Original Message-----
help! Somehow my DMaxer is not!

My code is Me!MaxNum = DMax
("CRInvNum", "tbl4Receipt", "[InvNum]=[cboInvNum]")

InvNum is my invoice number.

cboInvNum is the combo box selecting the invoice to make
a payment for.

CRInvNum is a unique payment number field, double, two
decimals, derived from InvNum with decimal representing
payment interations.

Example: invoice 12345; first payment CRInvNum is
12345.01; second payment is 12345.02, etc.

The counter works and writes the file correctly. But the
code is not returning 12345.02, rather its returning
12345.01.

What can be done to ensure the highest -- 12345.02 -- is
returned?

Thanks.


.
.
 
D

Dan Artuso

Anne,
Something is amiss somewhere. DMax will return the highest value.
I even tried it with your numbers.
Try this in the immediate window (press ctl-G):

?DMax("[CRInvNum]", "tbl4Receipt", "[InvNum]=12345")

What does it give you?

--
HTH
Dan Artuso, Access MVP


Anne said:
Thanks, Damien, but that still does not return
correctly. It gives me 12345.01, when there exists
12345.02 as well.

Other ideas?

Thanks,
Anne
-----Original Message-----
Ann,

personally, I don't like the Domain Aggregate function
(DMax, DLookup etc) so I'd use a Recordset:

Dim rst AS DAO.Recordset 'or ADODB.Recordset if you're
modern !

Set rst = currentdb.OpenRecordset("SELECT MAX(CRInvNum)
FROM tbl4Receipt WHERE InvNum = " & cboInvNum)

Me!MaxNum = rst(0)

rst.Close
Set rst = Nothing

Give it a try anyway and let me know how you get on !


damien
-----Original Message-----
help! Somehow my DMaxer is not!

My code is Me!MaxNum = DMax
("CRInvNum", "tbl4Receipt", "[InvNum]=[cboInvNum]")

InvNum is my invoice number.

cboInvNum is the combo box selecting the invoice to make
a payment for.

CRInvNum is a unique payment number field, double, two
decimals, derived from InvNum with decimal representing
payment interations.

Example: invoice 12345; first payment CRInvNum is
12345.01; second payment is 12345.02, etc.

The counter works and writes the file correctly. But the
code is not returning 12345.02, rather its returning
12345.01.

What can be done to ensure the highest -- 12345.02 -- is
returned?

Thanks.


.
.
 
A

Anne

Dan, et al,

THANKS! I found that what each of you have given me works
well. I had a criteria failure...pointing the wrong
way. Problem solved with the usual good help.

Thanks again,
Anne.
-----Original Message-----
Anne,
Something is amiss somewhere. DMax will return the highest value.
I even tried it with your numbers.
Try this in the immediate window (press ctl-G):

?DMax("[CRInvNum]", "tbl4Receipt", "[InvNum]=12345")

What does it give you?

--
HTH
Dan Artuso, Access MVP


Thanks, Damien, but that still does not return
correctly. It gives me 12345.01, when there exists
12345.02 as well.

Other ideas?

Thanks,
Anne
-----Original Message-----
Ann,

personally, I don't like the Domain Aggregate function
(DMax, DLookup etc) so I'd use a Recordset:

Dim rst AS DAO.Recordset 'or ADODB.Recordset if you're
modern !

Set rst = currentdb.OpenRecordset("SELECT MAX (CRInvNum)
FROM tbl4Receipt WHERE InvNum = " & cboInvNum)

Me!MaxNum = rst(0)

rst.Close
Set rst = Nothing

Give it a try anyway and let me know how you get on !


damien

-----Original Message-----
help! Somehow my DMaxer is not!

My code is Me!MaxNum = DMax
("CRInvNum", "tbl4Receipt", "[InvNum]=[cboInvNum]")

InvNum is my invoice number.

cboInvNum is the combo box selecting the invoice to make
a payment for.

CRInvNum is a unique payment number field, double, two
decimals, derived from InvNum with decimal representing
payment interations.

Example: invoice 12345; first payment CRInvNum is
12345.01; second payment is 12345.02, etc.

The counter works and writes the file correctly. But the
code is not returning 12345.02, rather its returning
12345.01.

What can be done to ensure the highest -- 12345.02 -- is
returned?

Thanks.


.

.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top