Error 3464

D

DS

I keep getting Data Type Mismatch
Any Clues?
Thanks
DS

Dim strWhere As String
Dim intChar As String
strWhere = "tblTest.[Number] = " & Me.Text3
intChar = Asc(Nz(DMax("Number", "tblTest", strWhere), "@"))
Me.TxtNumber.Value = Chr(intChar + 1)
 
K

kingston via AccessMonster.com

Try this:
Me.TxtNumber.Value = Chr(Eval(intChar + 1))
I keep getting Data Type Mismatch
Any Clues?
Thanks
DS

Dim strWhere As String
Dim intChar As String
strWhere = "tblTest.[Number] = " & Me.Text3
intChar = Asc(Nz(DMax("Number", "tblTest", strWhere), "@"))
Me.TxtNumber.Value = Chr(intChar + 1)
 
D

DS

Douglas said:
Change your declaration of intChar to:

Dim intChar As Integer
This works....

Dim strWhere As String
Dim intChar As String
intChar = Asc(Nz(DMax("NumberID", "tblTest", "NumberID = '" & Me.Text3 &
"'"), "@"))
Me.TxtNumber = Me.TxtNumber & Chr(intChar + 1)

But it doesnt do what it's suppose to, instead of doing this...
1
1A
1B
it does this...
1
2
3
Thanks
DS
 
D

Douglas J. Steele

It looks as though it should work.

What value are you getting for intChar?
 
D

DS

Douglas said:
It looks as though it should work.

What value are you getting for intChar?
If I type in 1 I get 2
If I type in 1A I get 2
it seems that it's advancing the number side of the entry.

Thanks
DS
 
D

Douglas J. Steele

The Asc function only returns the Ascii representation of the first
character in the string.

Try:

intChar = Asc(Right(Nz(DMax("NumberID", "tblTest", "NumberID = '" & Me.Text3
& "'"), "@"), 1))
 
D

DS

Douglas said:
The Asc function only returns the Ascii representation of the first
character in the string.

Try:

intChar = Asc(Right(Nz(DMax("NumberID", "tblTest", "NumberID = '" & Me.Text3
& "'"), "@"), 1))
That almost works. I can't believe it's so hard to find the Max record
for a number and letter. Am I going about it wrong?
Thanks
DS
 
D

DS

DS said:
That almost works. I can't believe it's so hard to find the Max record
for a number and letter. Am I going about it wrong?
Thanks
DS
This actually works, I figured out the syntax that Tony came up with
earlier. Only took 2 days!

Me.TxtNumber = DMax("[NumberID]", "tblTest", "Left(NumberID,Len(" &
Me.Text3 & ")) = '" & Me.Text3 & "'")

Thanks Everyone.
DS
 
G

Guest

Only trouble with that way is if you have the value 234a and enter 23 in
textbox3 it will only find say 23d, so not to be used as a *rough guess*
selection box where you want the highest number *beginning* with 23.

PS you didn't say you wanted to be able to enter a string rather than a
number into Text3. :p

For that I think you will be into looped code or query creation.

TonyT..


DS said:
DS said:
That almost works. I can't believe it's so hard to find the Max record
for a number and letter. Am I going about it wrong?
Thanks
DS
This actually works, I figured out the syntax that Tony came up with
earlier. Only took 2 days!

Me.TxtNumber = DMax("[NumberID]", "tblTest", "Left(NumberID,Len(" &
Me.Text3 & ")) = '" & Me.Text3 & "'")

Thanks Everyone.
DS
 

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