It's hard to follow what you are doing. MName is a number, but what is is
Len MName? Is it another field in the table, derived from the length of
MName? If so, you should calculate the value as needed rather than storing
it. The way I see it, if MName is 987, Len MName is 3. Is that correct?
You could try something like this as a test:
MsgBox Len(Me.txt_PCode) & "; " & Len(Me.cbo_PName)
If Len(Me.txt_PCode) <> Len(Me.cbo_PName) Then
Cancel = True
MsgBox "Invalid PCode"
End If
Or you could set a break point at the start of the code and step through it
checking the values as you go. Let me know if you need clarification on how
to do that.
>I have code on before update event of my form,
> but can't work.The form's data source is DProd_tbl.
[quoted text clipped - 26 lines]
>
> Shiro
shiro - 13 Aug 2008 08:39 GMT
Oh I'm sorry Bruce,
I mean "Len MName" data type is Number.So,
actually I want to compare the value of
txt_PCode with the value of "Len MName".
(Len MName is on the cbo_PName Column (1)).
Hope that make a sense.
Thank's
Rgds,
Shiro
> It's hard to follow what you are doing. MName is a number, but what is is
> Len MName? Is it another field in the table, derived from the length of
[quoted text clipped - 44 lines]
> >
> > Shiro
BruceM - 13 Aug 2008 12:20 GMT
If you are trying to compare two numeric values, don't use Len, which looks
at the length of the value (the number of characters it contains). Try:
If (Me.txt_PCode) <> Me.cbo_PName.Column(1) Then
Cancel = True
MsgBox "Invalid PCode"
Else
End If
However, if the data is already in one field, and you are essentially
requiring the user to copy the value to another field, what is the point?
> Oh I'm sorry Bruce,
> I mean "Len MName" data type is Number.So,
[quoted text clipped - 60 lines]
>> >
>> > Shiro
shiro - 14 Aug 2008 02:53 GMT
txt_PCode is text and it always change everyday.The thing that is not
change is number of the character (it's len).
> If you are trying to compare two numeric values, don't use Len, which looks
> at the length of the value (the number of characters it contains). Try:
[quoted text clipped - 72 lines]
> >> >
> >> > Shiro
BruceM - 14 Aug 2008 12:07 GMT
What exactly are you trying to do? Explain in non-Access terms, please.
> txt_PCode is text and it always change everyday.The thing that is not
> change is number of the character (it's len).
[quoted text clipped - 81 lines]
>> >> >
>> >> > Shiro