DMAX not working

  • Thread starter Thread starter Al
  • Start date Start date
A

Al

I have a form in Access 2000 where I want to make a
control visible if the user is at the max id number
(LOGID) in the control source table (LOG). The LOGID
field (named "ID") is also on the form and I think that is
where the problem is coming in.
I tried using "If me.ID = DMax([LOGID], "LOG") Then" but
I keep getting the LOGID of the current record instead of
the max id from the table. So I set up a variable and
tried it this way: Mid = DMax([LOGID], "LOG") and get the
same problem.
Why won't the DMAX function look at the table for the max
id?
TIA,
Al
 
Hi,
What happens if you type this in the Debug window?
?DMax([LOGID], "LOG")

Also, I'm suprised you were able to use Mid as a variable
as it's also a function.
 
erm... I hope I am not pointing out the obvious but are you on the record
that is the maximum ID? Failing that, I am not too sure if changing the
[LOGID] so it looks as follows would help:

If me.ID = DMax("LOGID", "LOG") Then

HTH,

Neil.
 
Try using the DMax outside of your expression. Get the
MaxID, save it as a variable as use the cariable in your
expression:

Dim lngMaxID as Long
lngMaxID = DMax("[LOGID]", "LOG")

If Me.ID = lngMaxID Then . . .

Hope this helps!

Howard Brody
 
No, I'm on the first record of my test table and there are
3 records in the table, all have LOGID's.
-----Original Message-----
erm... I hope I am not pointing out the obvious but are you on the record
that is the maximum ID? Failing that, I am not too sure if changing the
[LOGID] so it looks as follows would help:

If me.ID = DMax("LOGID", "LOG") Then

HTH,

Neil.

Al said:
I have a form in Access 2000 where I want to make a
control visible if the user is at the max id number
(LOGID) in the control source table (LOG). The LOGID
field (named "ID") is also on the form and I think that is
where the problem is coming in.
I tried using "If me.ID = DMax([LOGID], "LOG") Then" but
I keep getting the LOGID of the current record instead of
the max id from the table. So I set up a variable and
tried it this way: Mid = DMax([LOGID], "LOG") and get the
same problem.
Why won't the DMAX function look at the table for the max
id?
TIA,
Al


.
 
I tried that in the immediate window and still get the
same ID of the record I'm on instead of the max id in the
LOG table.

Sorry, Mid was a typo, its actually Maxid...
-----Original Message-----
Hi,
What happens if you type this in the Debug window?
?DMax([LOGID], "LOG")

Also, I'm suprised you were able to use Mid as a variable
as it's also a function.

--
HTH
Dan Artuso, Access MVP


I have a form in Access 2000 where I want to make a
control visible if the user is at the max id number
(LOGID) in the control source table (LOG). The LOGID
field (named "ID") is also on the form and I think that is
where the problem is coming in.
I tried using "If me.ID = DMax([LOGID], "LOG") Then" but
I keep getting the LOGID of the current record instead of
the max id from the table. So I set up a variable and
tried it this way: Mid = DMax([LOGID], "LOG") and get the
same problem.
Why won't the DMAX function look at the table for the max
id?
TIA,
Al


.
 
Hi,
Okay, do it with the form closed and see what you get.

--
HTH
Dan Artuso, Access MVP


Al said:
I tried that in the immediate window and still get the
same ID of the record I'm on instead of the max id in the
LOG table.

Sorry, Mid was a typo, its actually Maxid...
-----Original Message-----
Hi,
What happens if you type this in the Debug window?
?DMax([LOGID], "LOG")

Also, I'm suprised you were able to use Mid as a variable
as it's also a function.

--
HTH
Dan Artuso, Access MVP


I have a form in Access 2000 where I want to make a
control visible if the user is at the max id number
(LOGID) in the control source table (LOG). The LOGID
field (named "ID") is also on the form and I think that is
where the problem is coming in.
I tried using "If me.ID = DMax([LOGID], "LOG") Then" but
I keep getting the LOGID of the current record instead of
the max id from the table. So I set up a variable and
tried it this way: Mid = DMax([LOGID], "LOG") and get the
same problem.
Why won't the DMAX function look at the table for the max
id?
TIA,
Al


.
 
Wait a sec...
What is the data type of the LOGID field?

--
HTH
Dan Artuso, Access MVP


Al said:
I tried that in the immediate window and still get the
same ID of the record I'm on instead of the max id in the
LOG table.

Sorry, Mid was a typo, its actually Maxid...
-----Original Message-----
Hi,
What happens if you type this in the Debug window?
?DMax([LOGID], "LOG")

Also, I'm suprised you were able to use Mid as a variable
as it's also a function.

--
HTH
Dan Artuso, Access MVP


I have a form in Access 2000 where I want to make a
control visible if the user is at the max id number
(LOGID) in the control source table (LOG). The LOGID
field (named "ID") is also on the form and I think that is
where the problem is coming in.
I tried using "If me.ID = DMax([LOGID], "LOG") Then" but
I keep getting the LOGID of the current record instead of
the max id from the table. So I set up a variable and
tried it this way: Mid = DMax([LOGID], "LOG") and get the
same problem.
Why won't the DMAX function look at the table for the max
id?
TIA,
Al


.
 
LOGID is a number... and Maxid was declared an integer.
-----Original Message-----
Wait a sec...
What is the data type of the LOGID field?

--
HTH
Dan Artuso, Access MVP


I tried that in the immediate window and still get the
same ID of the record I'm on instead of the max id in the
LOG table.

Sorry, Mid was a typo, its actually Maxid...
-----Original Message-----
Hi,
What happens if you type this in the Debug window?
?DMax([LOGID], "LOG")

Also, I'm suprised you were able to use Mid as a variable
as it's also a function.

--
HTH
Dan Artuso, Access MVP


I have a form in Access 2000 where I want to make a
control visible if the user is at the max id number
(LOGID) in the control source table (LOG). The LOGID
field (named "ID") is also on the form and I think
that
is
where the problem is coming in.
I tried using "If me.ID = DMax([LOGID], "LOG") Then" but
I keep getting the LOGID of the current record
instead
of
the max id from the table. So I set up a variable and
tried it this way: Mid = DMax([LOGID], "LOG") and get the
same problem.
Why won't the DMAX function look at the table for the max
id?
TIA,
Al


.


.
 
Back
Top