Paste to a combo box

Does anyone have a suggestion for quirk free pasting to a combo box? I have a form which my users want to be able to copy and paste a project number from a previous form into a combo box on the new form. The numbers paste in but then we get a not-in-list flag, even though the value is in the list. If you paste the value in, backspace the last number and re-enter it, everything works fine. Not sure what is required to make this work all the time. Any suggestions are appreciated!

Thanks!
Michael
walkingbushAsked:
Who is Participating?
 
klilleyCommented:
Could you use the Notinlist event to strip the extra characters

ie

Private Sub Combo2_NotInList(NewData As String, Response As Integer)
Combo2 = Val(Combo2.Text)
Response = acDataErrContinue
End Sub
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Sounds like the paste string has extra characters, apparently hidden ... possibly a Line Feed and/or Carriage Return.

I would suggest.

See this link:

http://www.mvps.org/access/api/api0049.htm

The, create a custom right click menu - just for the combo box ... that will call a function (using the code above) that gets the clipboard value ... then you use the Replace() function to strip out an LF's and CR's ... may tabs, etc ...  then set the remain value into the combo.

I recently had to do a similar thing.

mx
0
 
Jeffrey CoachmanMIS LiasonCommented:
Also,

Instead of doing a copy and paste  from one form to another (which can be unreliable depending on the version of Office and anything else that might be in/on the users clipboard), why not simply code it in?

In the "Source" form, insert a "Copy To:" button.
Use code similar to this:

    Forms!frmDestination!txtDestination = Trim(Me.txtSource)

This bypasses any interaction with the clipboard and does a Trim to remove any leading or trailing spaces.
(You will still be advised to Use MX's "Replace" code to catch and oddball  LF's and CR's )

;-)

JeffCoachman

Here is a sample

JeffCoachman


db65.mdb
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
walkingbushAuthor Commented:
From a users standpoint, that isn't a very acceptable solution but oh well. I'll see what I can come up with. Thanks!
Michael
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
You don't have much choice.  Clearly what is being copied to the clipboard has erroneous characters present.  You need to strip them out.  And from my users stand point, it's a beautiful thing.

Control C to the Clipboard.
Right click over the text box - one menu item ... Paste Special.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Here is the easy way to create custom menus and toolbars and right click menus (aka Pop Ups):

http://www.jamiessoftware.tk/articles/menubars.html
       
Not sure it that article mentions it, but ... when you are in the Customize mode (dialog) ... if you hold down the Control key, you can drop and drag (ie, copy) menu items from one place to another ... handy for making a new menu that is similar another one.

mx
0
 
walkingbushAuthor Commented:
Oh, I understand from a programming perspective. It makes total sense. I'll give your suggestion a try but I've learned that if ctrl+c then ctrl+v doesn't work, someone is going to have a fit. What's weird is that they are selecting a numeric field (ProjNum) from a form utilizing the same record source as the time sheet form they are trying to paste to. Is it possible that it is being pasted as text instead of numeric data? Could that cause the problem?
Michael
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
That's an excellent idea ... and does seem to work.

mx
0
 
Jeffrey CoachmanMIS LiasonCommented:
walkingbush,

Who were you referring to in post:
http:#a23595505
?
JeffCoachman
0
 
Jeffrey CoachmanMIS LiasonCommented:
klilley,

Great solution.
;-)

Jeff
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.