user2433194
user2433194

Reputation: 86

trying to find record that includes # in vba

I have a access vba application. when i try to search for invoice using the

DoCmd.FindRecord strOrdNum, acEntire, False, acDown, False, acCurrent, True

It works when the strOrdNum is something like 123 or 1111. However for the records with strOrdNum that has "#" in them it does not work. For example for one of the records I have 11234#223, but it does not find it. Any ideas on how I can deal with these cases. Thanks

Upvotes: 0

Views: 94

Answers (1)

VBlades
VBlades

Reputation: 2251

As @OverMind mentioned, I think it's a wildcard issue. This worked for me. Replace:

DoCmd.FindRecord strOrdNum, acEntire, False, acDown, False, acCurrent, True

with:

DoCmd.FindRecord Replace(strOrdNum, "#", "[#]"), acEntire, False, acDown, False, acCurrent, True

This will force it to search for the literal.

Upvotes: 2

Related Questions