Connecting Tech Pros Worldwide Forums | Help | Site Map

Macro Problem

Net
Guest
 
Posts: n/a
#1: Apr 2 '07
Hi Please help. I have a database which requires a message to come up
when certain part numbers are added to it. I have solved part of this
by using a conditional macro eg [part no]= 54125 and using a msg
box. This works fine until a part no. which contains a letter is used
eg B6541. Access changes the criteria in the condition box to Part
No]=[b6541] and won't let me take the parameter boxes out. If I leave
them in I get an error message "type mismatch" Does anyone know a way
round this?
Regards


Rick Brandt
Guest
 
Posts: n/a
#2: Apr 2 '07

re: Macro Problem


Net wrote:
Quote:
Hi Please help. I have a database which requires a message to come up
when certain part numbers are added to it. I have solved part of this
by using a conditional macro eg [part no]= 54125 and using a msg
box. This works fine until a part no. which contains a letter is used
eg B6541. Access changes the criteria in the condition box to Part
No]=[b6541] and won't let me take the parameter boxes out. If I leave
them in I get an error message "type mismatch" Does anyone know a way
round this?
Regards
It's a text field so put quotes around the value.

[part no]= "54125"
[part no]= "b6541"

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


Net
Guest
 
Posts: n/a
#3: Apr 2 '07

re: Macro Problem


On Apr 2, 10:25 pm, "Rick Brandt" <rickbran...@hotmail.comwrote:
Quote:
Net wrote:
Quote:
Hi Please help. I have a database which requires a message to come up
when certain part numbers are added to it. I have solved part of this
by using a conditional macro eg [part no]= 54125 and using a msg
box. This works fine until a part no. which contains a letter is used
eg B6541. Access changes the criteria in the condition box to Part
No]=[b6541] and won't let me take the parameter boxes out. If I leave
them in I get an error message "type mismatch" Does anyone know a way
round this?
Regards
>
It's a text field so put quotes around the value.
>
[part no]= "54125"
[part no]= "b6541"
>
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Hi Rick,
Many thanks for that, just tried it - the parameters no longer get
applied but I'm still getting the "type mismatch" warning coming up.
Any ideas where I'm going wrong?
Thanks

Rick Brandt
Guest
 
Posts: n/a
#4: Apr 2 '07

re: Macro Problem


Net wrote:Hi Rick,
Quote:
Many thanks for that, just tried it - the parameters no longer get
applied but I'm still getting the "type mismatch" warning coming up.
Any ideas where I'm going wrong?
Thanks
Sorry, I'm not very familiar with macros. Where exactly is a type mismatch
error occurring?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com




Net
Guest
 
Posts: n/a
#5: Apr 2 '07

re: Macro Problem


On Apr 2, 10:42 pm, "Rick Brandt" <rickbran...@hotmail.comwrote:
Quote:
Net wrote:Hi Rick,
Quote:
Many thanks for that, just tried it - the parameters no longer get
applied but I'm still getting the "type mismatch" warning coming up.
Any ideas where I'm going wrong?
Thanks
>
Sorry, I'm not very familiar with macros. Where exactly is a type mismatch
error occurring?
>
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Hi Rick,
I'm using a form to update the database and I've got the macro set up
to operate after update in the form (the macro is set on my part
number entry). After entering the part number (with a letter in it)
The "type mismatch comes up. It is working a treat when I only have
numbers to put in and it is displaying the correct error message when
a problem part number is entered but it doesn't like me entering
letters in. It's driving me mad!
Regards


Marco Pagliero
Guest
 
Posts: n/a
#6: Apr 3 '07

re: Macro Problem


On 2 Apr., 23:50, "Net" <n...@fsmail.netwrote:
Quote:
On Apr 2, 10:42 pm, "Rick Brandt" <rickbran...@hotmail.comwrote:
>
Quote:
Net wrote:Hi Rick,
Quote:
Many thanks for that, just tried it - the parameters no longer get
applied but I'm still getting the "type mismatch" warning coming up.
Any ideas where I'm going wrong?
Thanks
>
Quote:
Sorry, I'm not very familiar with macros. Where exactly is a type mismatch
error occurring?
>
Quote:
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
>
Hi Rick,
I'm using a form to update the database and I've got the macro set up
to operate after update in the form (the macro is set on my part
number entry). After entering the part number (with a letter in it)
The "type mismatch comes up. It is working a treat when I only have
numbers to put in and it is displaying the correct error message when
a problem part number is entered but it doesn't like me entering
letters in. It's driving me mad!
Regards
Often this happen for example if you enter letters into a numeric
field.
Maybe the field in the table is marked as "numeric".
Try and mark it as "text".

Marco P

Net
Guest
 
Posts: n/a
#7: Apr 3 '07

re: Macro Problem


On Apr 3, 11:11 am, "Marco Pagliero" <mart...@web.dewrote:
Quote:
On 2 Apr., 23:50, "Net" <n...@fsmail.netwrote:
>
>
>
>
>
Quote:
On Apr 2, 10:42 pm, "Rick Brandt" <rickbran...@hotmail.comwrote:
>
Quote:
Quote:
Net wrote:Hi Rick,
Many thanks for that, just tried it - the parameters no longer get
applied but I'm still getting the "type mismatch" warning coming up.
Any ideas where I'm going wrong?
Thanks
>
Quote:
Quote:
Sorry, I'm not very familiar with macros. Where exactly is a type mismatch
error occurring?
>
Quote:
Quote:
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
>
Quote:
Hi Rick,
I'm using a form to update the database and I've got the macro set up
to operate after update in the form (the macro is set on my part
number entry). After entering the part number (with a letter in it)
The "type mismatch comes up. It is working a treat when I only have
numbers to put in and it is displaying the correct error message when
a problem part number is entered but it doesn't like me entering
letters in. It's driving me mad!
Regards
>
Often this happen for example if you enter letters into a numeric
field.
Maybe the field in the table is marked as "numeric".
Try and mark it as "text".
>
Marco P- Hide quoted text -
>
- Show quoted text -
Hi Marco,
Thanks but the field is marked as "text". I think I'm going to have to
learn a bit of programming!
Regards

Marco Pagliero
Guest
 
Posts: n/a
#8: Apr 4 '07

re: Macro Problem


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

Net
Guest
 
Posts: n/a
#9: Apr 5 '07

re: Macro Problem


On Apr 4, 6:11 pm, "Marco Pagliero" <mart...@web.dewrote:
Quote:
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
Hi Marco,

Many thanks for the trouble that you have been to. I got so frustrated
with the problem that I deleted the macro. I had 40 numbers that I
wanted to produce a "wrong " message so I used [part no] = "x234546"
and MsgBox "wrong". I reinstated all 40 part numbers and this time it
worked perfectly. I really do not know why My only thought is that
maybe I had a rogue character in amongst my part numbers.
Anyway it's all working well and I think you are a star.
Thanks,
Net

Closed Thread


Similar Microsoft Access / VBA bytes