On 3 Apr., 20:37, "Net" <n...@fsmail.netwrote:
Quote:
Thanks but the field is marked as "text". I think I'm going to have to
learn a bit of programming!
It would be generally very useful if you could write subs and
functions but for this specific problem I don't think it would help,
as most "type mismatch" come from some type mismatch.
So I did this: I put a field named PartNo of type 'text' in some
table, then I put on some form a control named PartNo and bound it to
the field PartNo in the table.
Then I made a macro 'test' with the condition: [PartNo]="123456" and
the action: MessageBox "wrong", and set this macro in the event
AfterUpdate of the form.
When I enter 654321 in the form nothing happens, when I enter 123456 I
get a MsgBox "wrong".
Then I changed the condition of 'test' from [PartNo]="123456" to
[PartNo]="X23456"
When I enter 654321 in the form nothing happens, whem I enter X23456 I
get a MsgBox "wrong".
The I went to editing the table and changed the data type of field
PartNo from text to number and saved.
After that when I enter 654321 in the form nothing happens, whem I
enter X23456 I get a message that the value I entered is not allowed
for this field. In my opinion this proves that the type mismatch comes
when saving the field and before the macro is called.
I think you should get the error even if you delete the macro from the
event AfterUpdate and I cannot imagine any other cause to the problem,
than the field PartNo being of type number. Maybe you look in the
wrong table.
I don't think you can work around this with some programming, but you
can try: Go to modules and make a new one, then write in it
sub test(ByVal A as variant)
if A="X23456" then MsgBox "wrong"
if A="Y65432" then MsgBox "wrong"
.....
end sub
and save, then go to the form and write in procedure
PartNo_AfterUpdate():
call test([PartNo])
And let me know if you find a different cause at last, I'm very
interested in learning something new.
Greetings
Marco P