?
Solved

Paste to a combo box

Posted on 2009-02-09
10
Medium Priority
?
453 Views
Last Modified: 2013-11-28
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
0
Comment
Question by:walkingbush
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 75
ID: 23592011
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
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 23592579
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
 

Author Comment

by:walkingbush
ID: 23595505
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 75
ID: 23595525
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
 
LVL 75
ID: 23595528
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
 

Author Comment

by:walkingbush
ID: 23595668
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
 
LVL 4

Accepted Solution

by:
klilley earned 750 total points
ID: 23596373
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
 
LVL 75
ID: 23597236
That's an excellent idea ... and does seem to work.

mx
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 23598144
walkingbush,

Who were you referring to in post:
http:#a23595505
?
JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 23690047
klilley,

Great solution.
;-)

Jeff
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question