MS Access Controlling Copy/Paste of Data from Continuous Form - ms-access

I have a user that is dealing with an Access Database continuous forms page where they can perform a bunch of filtering and data entry.
Occasionally the user wants to be able to select a few rows from this form and paste them directly into an email. Outlook formats the data into a table pretty nicely on its own but the problem we're having is that dropdown controls from the header are included in the pasted data as you can see below:
Employee_Absences
drpEmployee drpOrgDescrip lstTimeCode txtToDate txtFromDate chkShowExcused DESCR AbsenceDate Hours Excused_Hours Time Code employee_lookup.ORG_DESCRIP ImportedDate
6/2/2009 1/1/2009 0 Bob 1/4/2009 4 0 VAC Medical 5/7/2009 4:51:31 PM
6/2/2009 1/1/2009 0 Bill 1/4/2009 6 0 VAC Medical 5/7/2009 4:51:31 PM
6/2/2009 1/1/2009 0 Betty 1/4/2009 4 0 VAC Medical 5/7/2009 4:51:31 PM
6/2/2009 1/1/2009 0 Beth 1/5/2009 2 0 VAC Gamers 5/7/2009 4:51:31 PM
The user doesn't want to bother with deleting and reordering columns every time they want to include a couple rows in an email and it would be fairly unfriendly to force them into a separate report or datasheet just to get two or three rows. I've tried messing with the order of the parameters in the query that is populating the form but this doesn't help at all.
Is there some sort of Copy-to-Clipboard event that I can hook into and do some magic to the data rows? Any other suggestions?

This is surely a layout problem on the form. Selecting rows of a continuous form should not copy the data from controls in the form header.
Perhaps I've misunderstood the problem?
It certainly is possible to put data on the clipboard. See this page:
Copy variables/control contents to memory
But for pasting into an email, you'd need plain text and the email would need to be displayed in a fixed-width font. Unless you want to write HTML, there is no easy way to format a table that will paste into a non-plain-text email. If they are sending in HTML (which they oughtn't be), an HTML table will work. If they are using RTF (and they oughtn't be), I don't know what happens if you paste HTML.
Try to figure out why the form header control is getting copied. My bet is that the user is not defining the initial selection correctly, and you teach them to do that (or engineer the subform to prevent it), you won't have to program anything -- which is the whole beauty of Access.
On another note, I don't believe in allowing edits in continuous or datasheet forms because if you need dynamic combo boxes and the like for data validation, it can lead to all sorts of problems. Instead, I use continuous and datasheet forms as lists and have a detail subform bound to the PK of the continuous/datasheet form so that when you select a record in the continuous/datasheet form, the data will appear in the editable detail subform.
I have just had too many problems with editing continuous and datasheet forms and that's why I've done that. The only exception I make for that is in an invoice-type form, where there is no good way to do it otherwise.

Related

Input multiple objects of a class in a single HTML or Flask form

For the sake of simplicity, say I want to build a shopping list using Flask using a table in a format that looks like this:
Name
Cost
Amount
Sell-By
Apples
1
5
2022-07-18
Bananas
0.7
7
2022-07-20
I want the shopping list page to initially look like this, with a user able to add any number of items before submission
Name
Cost
Amount
Sell-By
(User input)
(User input)
(User input)
(User input)
When submitted each line should be able to be initiated as a SQLAlchemy object and saved into a database.
I've tried using FieldList and FormField from WTForms but can't quite get the hang of it (and don't really feel it's appropriate in this situation anyway). I don't usually struggle with forms, but having multiple instances of the same form AND trying to put that in a dynamically generated table is really tripping me up, so any pointers are welcome.
The content/size of a shopping list should be adjustable during writing.
Therefore i suggest you take a look at JavaScript and add a simple Button that generates a new row´each time you click it. Each row then contains the needed String or Number fields.
If you send the form you can simply move the entries to your Database

MS Access popup form conditional on combobox value

I am working on a database to store a heap of animal behavioural observation data and am working on creating a form to input data (one of many forms). The main form feeds into a table called "FocalSample" and the subform feeds into a "FocalData" table.
This is the form at present
There will be multiple records in the subform to a single overarching sample, a sample is a 10 minute period and a single animals behaviour is documented over that 10 minutes, noting time in minutes and seconds to calculate duration of time spent in each behaviour.
I need popup forms to come up depending on what is selected in the "Behaviour Type" field of the subform, as the kind of data recorded for a "feed" observation compared to a "social" observation is very different. I have created separate tables for the different behaviour types of data and forms that are set as "popup" forms, but need help with the code to get it to do what I need! :P
I have been trying a variation of the following code that I found here (http://www.justskins.com/forums/pop-up-form-based-238440.html)
Private Sub Campaign_AfterUpdate()
Dim strFormName As String
Select Me.Campaign.Value
Case "In Honor", "In Memory"
strFormName = "HonorMemory"
Case "In-Kind"
strFormName = "InKind"
End Select
DoCmd.OpenForm strFormName, , , , , acDialog
End Sub
But I keep getting an error message after the first row.
Here is the error and code screen
Similar to the other forum link I attached, I also need the popup form to draw a lot of info from the main form, but I'd just be happy to be able to get the popup forms working at the moment.
Sorry for so much detail - I am in a remote area of Africa and only have limited access to internet so am trying to give as much info up front!
Example of popup form - you might be able to determine fields that will feed off the focalsample form
Another example of a popup form - different behaviour type to the previous
EDIT
I have jigged the code now based off previous response but am not getting a different error.This is the code with the error line highlighted - I am not sure what table name to add if any
Error code
The line Select Me.Campaign.Value should read Select Case Me.Campaign.Value.

Access 2010 - Bound Textbox - Only updating newest record created

I am trying to update the textbox for the current request that I have opened. After making changes to the bound textbox (regardless of the record number current being edited) it modifies the tblVendorRequests.VendorDiscussionNotes for the newest request created within the table.
My form is a Single Form
My record source for my form is a table (tblVendorRequests)
My textbox (txtVenConLog) is using tblVendorRequests.VendorDiscussionNotes as its control source
For instance, say I am trying to add notes "Hello World" to request number 242. Request 242's notes remain the same, but the "Hello World is added to the newest record instead (overwriting the existing text that was in the request).
I have done a good amount of searching on the topic, and have not found a satisfactory answer on why this would be.
Any ideas would highly appreciated!
I redesigned my form to split the functions into 2 separate forms and that seems to have resolved the issue. I believe the issue was that when I 'opened' a record, it was not behaving like it would if the record-opening function resulted in calling a form to open with specific criteria.

Self Containing Form for Heirarchical Data

I'm attempting to store legislation inside an access database. Due to the inconsistent numbering and heading/subheading use, I was intending on storing the data in a flat table, with a "parent" column storing the ID to the heading, or the subheading, or the section text etc etc etc.
So - for instance
ID Section Parent Description
0 1 Purposes of the act
1 a 0 The purpose of this act is to:
2 i 1 Manage data efficiently
3 ii 1 Test access
4 b 0 More data goes here
would represent the data
1 - Purposes of the act
a - The purpose of this act is to
i - Manage Data Efficiently
ii - Test Access
b - More Data goes here
My issue is in using forms to effectively edit the data. The best approach (from what I see) would be to embed a form within itself as a subform - which is evidently not allowed. My intention was to have 2 new buttons - one for new item, one for new child. The latter which would create a child item and show it (and the other child items) in the subform.
Is there another way to do this?
I'd have a continuous form displaying the whole law/by-law (you should be able to format it for display in the source query); however, each section could be double-clicked on to open another form (perhaps modal) to edit the section.
Logically, you'd have controls for inserting, deleting, indenting and outdenting particular sections.
I suspect you will also want to include an "order" column for each section. Suppose you want to change the order of 1.a.i and 1.a.ii. You can't change the ID column, because it's probably an Auto-Number.
Of course, an obvious question is why not just store the law/by-law in MS Word and store references to it's location in the DB

MS Access 2003/2007 - Passing data through a variable on unbound forms vs. a hidden text box

Ok so I hope the title of the question matches what I about to ask, but here is what I am trying to get at:
So I have an access database that uses a number of unbound forms, and the purpose of the forms are to collect data and save to various tables with VBA click events using SQL statements (INSERT or UPDATE based on whether the ID of the record is present on the form in a hidden text box). When entering a new record (via INSERT), I get the row number with
MyRow = db.openrecordset("SELECT ##Identity")(0) 'thanks David
So you maybe getting the picture. If I have another form that relates to the first form in terms of the record, I just open a recordset and pass that value to another hidden text box.
So my question is, is there a better way to do this regarding passing that value (or just using that value) using a variable instead of this awkward method. So I realize a lot of folks are going to go with the obvious answer of, "Why not just make your forms bound instead of all this code"...and I am sure that is a valid answer, however I inherited this database which was already put together like this, and re-structuring it would be a daunting task.
Any and all advice, or learning resources are greatly appreciated, as they always are!
I use unbound controls on forms for all these kinds of values. The current solution of using an unbound form is sounder than using global or form level variables. If I recall the details correctly while debugging code and you hit the stop button you lose all global or form level variables. Or if the user hits an unhandled error.
Have you looked at OpenArgs?
DoCmd.OpenForm "Form1", , , , , , "Hello"