dmax for client code

  • Thread starter Thread starter JohnE
  • Start date Start date
J

JohnE

I am attempting to have a field fill automatically thru
the Default property a client code 1 greater then the
previous client code. The client code will be an
alphanumeric code. An example is CAM0102. I have been
able to get the numbering but not the CAM part. I have
tried the following:
=DMax("[TestCode]","TEST") & "CAM0"+1
but I get #Error in the field. No doubt this is not
correct. Can someone see the #Error of my way? Or even a
better way of working it?
Thanks in advance to anyone who responds.
*** John
 
Try =DMax("[TestCode]","TEST")+1 & "CAM0" or possibly
=cstr(DMax("[TestCode]","TEST")+1) & "CAM0"

One problem with your current code is that "CAM0"+1 is taking a string and
trying to add a number.
 
Rob, neither of them worked. I might rethink about how
the client code style should be.
*** John

-----Original Message-----
Try =DMax("[TestCode]","TEST")+1 & "CAM0" or possibly
=cstr(DMax("[TestCode]","TEST")+1) & "CAM0"

One problem with your current code is that "CAM0"+1 is taking a string and
trying to add a number.


I am attempting to have a field fill automatically thru
the Default property a client code 1 greater then the
previous client code. The client code will be an
alphanumeric code. An example is CAM0102. I have been
able to get the numbering but not the CAM part. I have
tried the following:
=DMax("[TestCode]","TEST") & "CAM0"+1
but I get #Error in the field. No doubt this is not
correct. Can someone see the #Error of my way? Or even a
better way of working it?
Thanks in advance to anyone who responds.
*** John


.
 
Is TestCode a numeric field?


JohnE said:
Rob, neither of them worked. I might rethink about how
the client code style should be.
*** John

-----Original Message-----
Try =DMax("[TestCode]","TEST")+1 & "CAM0" or possibly
=cstr(DMax("[TestCode]","TEST")+1) & "CAM0"

One problem with your current code is that "CAM0"+1 is taking a string and
trying to add a number.


I am attempting to have a field fill automatically thru
the Default property a client code 1 greater then the
previous client code. The client code will be an
alphanumeric code. An example is CAM0102. I have been
able to get the numbering but not the CAM part. I have
tried the following:
=DMax("[TestCode]","TEST") & "CAM0"+1
but I get #Error in the field. No doubt this is not
correct. Can someone see the #Error of my way? Or even a
better way of working it?
Thanks in advance to anyone who responds.
*** John


.
 
TestCode's datatype is text.

-----Original Message-----
Is TestCode a numeric field?


Rob, neither of them worked. I might rethink about how
the client code style should be.
*** John

-----Original Message-----
Try =DMax("[TestCode]","TEST")+1 & "CAM0" or possibly
=cstr(DMax("[TestCode]","TEST")+1) & "CAM0"

One problem with your current code is that "CAM0"+1 is taking a string and
trying to add a number.


I am attempting to have a field fill automatically thru
the Default property a client code 1 greater then the
previous client code. The client code will be an
alphanumeric code. An example is CAM0102. I have been
able to get the numbering but not the CAM part. I have
tried the following:
=DMax("[TestCode]","TEST") & "CAM0"+1
but I get #Error in the field. No doubt this is not
correct. Can someone see the #Error of my way? Or even a
better way of working it?
Thanks in advance to anyone who responds.
*** John


.


.
 
That would be a problem.

Firstly, you cannot take a text field and add 1 to it (or any other kind of
calculation) - although you could get around that by using the Val
function - something like val(DMax("[TestCode]","TEST"))

Second thing is more of a problem though... if it's a text field then 9 is
later in the alphabet than 12 so your dmax is going to be picking out
incorrect values.

I'd suggest switching it to numeric format.


JohnE said:
TestCode's datatype is text.

-----Original Message-----
Is TestCode a numeric field?


Rob, neither of them worked. I might rethink about how
the client code style should be.
*** John


-----Original Message-----
Try =DMax("[TestCode]","TEST")+1 & "CAM0" or possibly
=cstr(DMax("[TestCode]","TEST")+1) & "CAM0"

One problem with your current code is that "CAM0"+1 is
taking a string and
trying to add a number.


message
I am attempting to have a field fill automatically thru
the Default property a client code 1 greater then the
previous client code. The client code will be an
alphanumeric code. An example is CAM0102. I have been
able to get the numbering but not the CAM part. I have
tried the following:
=DMax("[TestCode]","TEST") & "CAM0"+1
but I get #Error in the field. No doubt this is not
correct. Can someone see the #Error of my way? Or
even a
better way of working it?
Thanks in advance to anyone who responds.
*** John


.


.
 
Rob, thanks for the assistance on this. I have gone back
to the higher ups and informed them they need to rethink
the client code issue into a more unique method, like the
autonumber. They are considering.
Again, thanks.
*** John

-----Original Message-----
That would be a problem.

Firstly, you cannot take a text field and add 1 to it (or any other kind of
calculation) - although you could get around that by using the Val
function - something like val(DMax("[TestCode]","TEST"))

Second thing is more of a problem though... if it's a text field then 9 is
later in the alphabet than 12 so your dmax is going to be picking out
incorrect values.

I'd suggest switching it to numeric format.


TestCode's datatype is text.

-----Original Message-----
Is TestCode a numeric field?


Rob, neither of them worked. I might rethink about how
the client code style should be.
*** John


-----Original Message-----
Try =DMax("[TestCode]","TEST")+1 & "CAM0" or possibly
=cstr(DMax("[TestCode]","TEST")+1) & "CAM0"

One problem with your current code is that "CAM0"+1 is
taking a string and
trying to add a number.


message
I am attempting to have a field fill automatically thru
the Default property a client code 1 greater then the
previous client code. The client code will be an
alphanumeric code. An example is CAM0102. I have been
able to get the numbering but not the CAM part. I have
tried the following:
=DMax("[TestCode]","TEST") & "CAM0"+1
but I get #Error in the field. No doubt this is not
correct. Can someone see the #Error of my way? Or
even a
better way of working it?
Thanks in advance to anyone who responds.
*** John


.



.


.
 
Back
Top