Avatar of Fordraiders
FordraidersFlag for United States of America

asked on 

trim dropdown value before executing query

Access 2010 vba

I have a combobox where the row source is a query.
When a value/copied and pasted./ typed into the combo box.

The query brings back the result.

I want to trim the value pasted before the query executes ?


me.cbo_Names = trim(me.cbo_names)

Thanks
fordraiders
Microsoft Access

Avatar of undefined
Last Comment
Jeffrey Coachman
SOLUTION
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Also, what is the purpose of trimming the value?  Trim() just removes extra space.  Do you need something more than that?
ASKER CERTIFIED SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Fordraiders
Fordraiders
Flag of United States of America image

ASKER

just trying to remove spaces
Avatar of Fordraiders
Fordraiders
Flag of United States of America image

ASKER

Thanks all...
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

you're welcome ~ happy to help

if the combo is not limited to the list, provided it is a string, you can do this on the control After Update event:
with me.controlname
   if isnull(.value) then exit sub
   .value = trim(.value)
end with

Open in new window

Glad you were able to get what you were after.
;-)
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo