Solved

Custom Menu Cut, Copy & Paste

Posted on 2006-11-02
7
425 Views
Last Modified: 2008-03-03
Hello, Experts

I am trying to make an application that uses a custom menu bar for most actions, rather than my typical collection of buttons.  Most things are going well, but I am getting hung up on Cut, Copy and Paste.  I have thought through the problem down various paths and cannot find one I am happy with.  I am hoping to get some feedback.

I have a main form that is always open and it has various text boxes and a few subforms in continuous mode.  The problem is that standard Cut/Copy/Paste works great for text boxes and simple subforms, but doesn't work correctly if the user selects an entire record in a subform that links to other tables in a 1-to-many relationship.  All the information could be deleted by the Cut using cascading delete, but it will not be properly saved by the Cut or Copy or Pasted correcly.

But if I replace the standard Cut, Copy, Paste then I have to somehow handle disabling them in various situtations --like no text selection, focus is on a command button, etc.  This seems time consuming and error prone.

Ideally, I could simply replace Cut, etc. with "Cut Entire Record", etc. when an entire record is selected and show standard Cut, etc. when it is not.  I could track the record selector being clicked with the subform's OnMouseDown event, but I see no way to easily track when the focus leaves the record selector.

My final idea is to hide the record selector and any way for the user to select an entire record and make a fake one myself.  Then I would never have o worry about standard Cut morphing into incorrect full record Cut.  This could work but I always find these little tweaks turn into hair pullers once I get into them.

So that's where I am...1. Drop standard C/C/P and lose auto disabling,  2. Disable standard C/C/P when record is selected, 3. Drop record selectors and fake my own.

If you made it this far, thanks!  Any thoughts...?

Kindest Regards,
Greg
0
Comment
Question by:gsatir
  • 3
  • 2
7 Comments
 
LVL 54

Expert Comment

by:nico5038
Comment Utility
Hi Greg,

In a similar situation (related records) I used a temp table solution.
When the user starts adding/updating he gets a copy of the information and is working on the copied rows in temp tables. This will allow the addition and deletion of related records and when the user presses [Save] the original rows are deleted and the new rows are added.
When the user presses the [Cancel] you do just nothing :-)

Getting the idea ?

Nic;o)
0
 

Author Comment

by:gsatir
Comment Utility
I can see how using a temp table would  be a good idea.  I tried to store the copied information in a listbox, but if it gets changed (or "deleted" by the cut) then the listbox information changes as well.  Since it will never be that much information  cut and pasted, is there a simple way to, say, open a recordset where you know it won't change regardless of what happens to the underlying records.  Kind of the opposite of what we usually want in a DB :-)

BTW, I went with #2 above and it seems to be working.

Greg
0
 
LVL 54

Accepted Solution

by:
nico5038 earned 375 total points
Comment Utility
For not changing the real information the temptable is the only way I know to allow users to manipulate data without effecting the underlaying data.
It will also stay "stable" as long as you don't recreate the temp table.

For a record oriented cut/copy/paste you could use also a temp table with just one record.
For the cut/copy issue:
currentdb.execute ("insert into tblTemp (select * from tblSource where key=" & me.subform.form.key & ")")
currentdb.execute ("delete * from tblSource where key=" & me.subform.form.key)
now the row is in the temp table and you can add it with:
currentdb.execute ("insert into tblTarget (select * from tblSource where key=" & me.subform.form.key & ")")
Thus the same row can be copied to multiple tables when needed.
Just take care that the target table doesn't have an autonumber key, else all fields except the key field should be used in the insert instead of the "*".

Nic;o)
0
 

Author Comment

by:gsatir
Comment Utility
> For not changing the real information the temptable is the only way I know to allow users to manipulate data without
> effecting the underlaying data.

This sounds like a different issue than I am facing...I want a way to create an internal "clipboard" that can be used to cut/copy and paste records.  So the clipboard will never be editted, but for a copy the original might be editted and for a cut it is deleted.  Is there a way to open a recordset that says "once this recordset is populated, do not change it based on other changes made later."  So I could open a recordset on a cut/copy and then delete or allow edits to the original data and still have my clipboard intact.

Possible?
Greg
0
 
LVL 54

Expert Comment

by:nico5038
Comment Utility
The temptable approach will give you that "clipboard"as the row in the table will remain the same and can be inserted many times.
The cut action will require you to store the current record in the table and delete the original record. All needed is to empty the temp table before a cut or copy record is added so only one record will reside.
When your application can be used by multiple users, you'll need to add a unique ID (being the username you can get from the Environ( "username") function) so there will be no mixup. Using a temp table will even keep the last record fixed over multiple Access sessions.

Your requirement "once this recordset is populated, do not change it based on other changes made later."  should be controlled by the application as we can't protect direct updates in tables by the uuser, unless you're using an .mde for the user.

Nic;o)
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now