I love DMAX - not!

D

DubboPete

Hi all,

I am trying to look up the last entry in a field which contains
odometer readings, based on the vehicle registration chosen in Combo1,
which ties back to [Fleet Number] in table CALCS.

The field I want to focus on isEndOdo. It's also in the table CALCS.
I am getting runtime error 2001 every time I try to run it.

Here's the code in the after update event of Combo1:

Me.EndOdo = DMax("[EndOodo]", "calcs", "[fleet number] = " &
Forms!FuelCalcs![Combo1])

Any clues out there?

cheers
DubboPete
 
A

Allen Browne

If you open the calcs table in design view, what is the Data Type of the
[fleet number] field?

If Text, you need extra quotes:
Me.EndOdo = DMax("[EndOodo]", "calcs",
"[fleet number] = """ & Forms!FuelCalcs![Combo1] & """")

If that doesn't work, check these properties of the combo:
Row Source
Bound Column
The RowSource is probably a table name, query name, or SQL statement.
The Bound Column tells you which field from the RowSource is the value of
the combo. This has to be the column that matches your fleet number.

Another way to test this is to open the Immediate window (Ctrl+G), and
enter:
? Forms!FuelCalcs![Combo1]
to discover what value Access is using. You can also enter:
? DMax("[EndOodo]", "calcs",
"[fleet number] = """ & Forms!FuelCalcs![Combo1] & """")
(as a single line), and work with it there until you solve the issue.
 
D

DubboPete

Thanks Allen,

The quotes for the text field did the trick...
another one for the memory banks!

Pete

Allen said:
If you open the calcs table in design view, what is the Data Type of the
[fleet number] field?

If Text, you need extra quotes:
Me.EndOdo = DMax("[EndOodo]", "calcs",
"[fleet number] = """ & Forms!FuelCalcs![Combo1] & """")

If that doesn't work, check these properties of the combo:
Row Source
Bound Column
The RowSource is probably a table name, query name, or SQL statement.
The Bound Column tells you which field from the RowSource is the value of
the combo. This has to be the column that matches your fleet number.

Another way to test this is to open the Immediate window (Ctrl+G), and
enter:
? Forms!FuelCalcs![Combo1]
to discover what value Access is using. You can also enter:
? DMax("[EndOodo]", "calcs",
"[fleet number] = """ & Forms!FuelCalcs![Combo1] & """")
(as a single line), and work with it there until you solve the issue.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

DubboPete said:
Hi all,

I am trying to look up the last entry in a field which contains
odometer readings, based on the vehicle registration chosen in Combo1,
which ties back to [Fleet Number] in table CALCS.

The field I want to focus on isEndOdo. It's also in the table CALCS.
I am getting runtime error 2001 every time I try to run it.

Here's the code in the after update event of Combo1:

Me.EndOdo = DMax("[EndOodo]", "calcs", "[fleet number] = " &
Forms!FuelCalcs![Combo1])

Any clues out there?

cheers
DubboPete
 
A

Allen Browne

Excellent, Pete.

There's a new article here if it helps:
Quotation marks within quotes
at:
http://allenbrowne.com/casu-17.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

DubboPete said:
Thanks Allen,

The quotes for the text field did the trick...
another one for the memory banks!

Pete

Allen said:
If you open the calcs table in design view, what is the Data Type of the
[fleet number] field?

If Text, you need extra quotes:
Me.EndOdo = DMax("[EndOodo]", "calcs",
"[fleet number] = """ & Forms!FuelCalcs![Combo1] & """")

If that doesn't work, check these properties of the combo:
Row Source
Bound Column
The RowSource is probably a table name, query name, or SQL statement.
The Bound Column tells you which field from the RowSource is the value of
the combo. This has to be the column that matches your fleet number.

Another way to test this is to open the Immediate window (Ctrl+G), and
enter:
? Forms!FuelCalcs![Combo1]
to discover what value Access is using. You can also enter:
? DMax("[EndOodo]", "calcs",
"[fleet number] = """ & Forms!FuelCalcs![Combo1] & """")
(as a single line), and work with it there until you solve the issue.
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 

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