Create multiple records in a table using 1 form in MS Access 2013 - forms

I know this has been asked before, but I couldn't figure it out in my case.
I have a table called t_JOB, and one of the columns is "PO #". Each PO # can have multiple PO Line Items. So I created a table called t_PURCHASES_PO_ByLI which has the columns "PO #", "Line #" and "Line Amount". PO # from the t_Job table is a primary key and is a 1 to many relationship with the PO # in the t_PURCHASES_PO_ByLI Line Items table.
I want the user to be able to enter the PO # in the t_JOB table as well as the line # and line amount for as many lines items as they want in 1 form. Now after some research I added a subform and was able to do this BUT, it only worked if I entered 1 line # and line amount. I had the textboxes for more but it wouldn't send the values.
I understand forms are supposed to be for 1 record only, but in this case it would make sense for the user to be able to enter the PO #, and well as all of the line #'s and amounts associated with it all at once. How can I do this or is there a different way to go about solving this?
Edit
Here is what I enter in my form:
Notice how it only stores the value 5 for the Line #'s? The default values for each are 1, 2, 3 respectively. Only when the form first loads and I switch from the Line #1 textbox to the description #1 textbox does it change to 5. If I go and change it back to 1, all the values for line # switch to 1. They don't stay at 1, 2 and 3.
Also, notice how all of the description textboxes are the same? I don't want this to be the case, but whenever I edit one of the description boxes, it edits them all. How can I make them unique?
Here is what gets written to the t_JOB table:
Here is the data stored in the t_PURCHASES_PO_ByLI:
Also, I read up on Multiple-item forms, but I can't figure out how to add one as a sub-form. Any ideas on how to do that?

Your subform Line Items seems to be a "single form", i.e. its DefaultView property is Single Form.
And you have 3 sets of controls, probably each of them with the same control source, therefore they will always show the same value.
Change the Default view to Continuous Forms, and remove all but one instance of each field (remove the #2 and #3 controls). Then you will be able to enter multiple records in the Line table.

Related

Filemaker: behavior of portal rows

I am creating a contacts database using FileMaker Pro 19. Part of the relationship diagram is shown below:
For each Person record, I have zero or more Phone records, each corresponding to exactly one IDDCode record.
In the layout for editing Person records, I have a portal (with all default options) pointing to the Phone table. In each portal row I have edit boxes for the Phone::Label and Phone::PhoneNumber fields, and a drop-down control with "Display data from" = IDDCode::DisplayCode and the "Values from" list set up as:
Hopefully it is clear enough what I am aiming for. What actually happens is not even close to that. Among the many unexpected behaviors:
Changing one drop-down sets the value in all rows
The values shown in the drop-down do not necessarily correspond to the values in the Phone table
When I open the drop-down list, the highlighted default is off by one (e.g. if IDDCodeID is 39, the value for IDDCodeID 40 is highlighted)
Some of the edit boxes are missing, e.g. the second row in the example image should have a phone number filled in
The portal does correctly display the existing (imported) data, though. Here is an example of what I see when I try to use the layout:
QUESTION:
Obviously the way I have set this up is wrong (I am familiar with databases but brand new to Filemaker). Rather than address the problems with my setup point by point, I am hoping to find out what is the right way to do this in Filemaker?

Listing multiple values from the same record multiple times in crystal reports

I have a PDF "student record" that we need to print the values on. Because of this, all values must be printed where they are listed on the pdf and I can't just put everything in a list format. I have attached a screenshot of the bottom lefthand corner of the PDF as an example.
Obviously, grouping wouldn't allow me to print out different values of the same record like this. It probably wouldn't allow me top specify which record goes on which line exactly either.
Is it possible to make a formula field that pulls the correct record for each line?
For example, dragging the "Student.Relationship.FirstName" field always lists whatever 'first' relationship is on their record.
Can I make a formula that specifies that will pull the second relationship record instead of defaulting to the first?
Can I make a formula that can specify "student.relationship.firstname" WHERE student.relationship.type = "father"?
SUBREPORTS.. I think that is what you need. Create a grouping on STUDENT, add Extra sections for the same group and on each section insert a different Subreport that has details as required.
Pass the Student ID as the sub-report link.

Microsoft Access - I want my mainform to create X records in subform base on fields automatically

I been putting a lot of thought into the logic behind this, and I can't seem to figure out the best way to handle this problem.
1 - Afterinsert
2 - unbound fields + button to insert X times
3 - I am open for suggestions
The form
The relationship
I was debating on using AfterInsert to handle everything. Since NoOfBoxes will decide the amount of records and I would only need to duplicate the value of MergeNo and isCommission to the subform. But the problem is, I need to also auto fill the item, which made me think of solutions number 2.
The reasoning behind going with number 2 is; my receive report header doesn't contains the item information and since a subform can only have 1 type of item but multiple of them. I was hitting toward number 2.
Solution number 2 would be multiple unbound fields which pulled the information into a combo box, or enter the information needed and hit a button which will then transfer all that data to the subform and create the correct amount of records.
unbound fields = itemcode, mergeNo, isCommission, and NoOfBoxes.
I think you need a Numbers table with integers from 1 or 0 to an appropriate number, you can then say something like:
INSERT INTO ATable ( MergeNo, IsCommission )
SELECT [Forms]![aForm]![MergeNo] AS MergeNo,
[Forms]![aForm]![IsCommission ] AS IsCommission
FROM Numbers
WHERE Numbers.Number<=[Forms]![aForm]![NoOfBoxes]
Do not forget that if the numbers table starts from 0, it is less than, not less than or equal to.

Filemaker 12 -- display one value, store another

I'm building a database in FileMaker 12 that will, among other things, keep a list of jobs (indicated by numeric ID) and the employees who had billable time for that job.
Given three tables:
Employee ( empName, empID, salary, ... )
JobHours ( empID, jobID, hrsWorked, ... , refID)
JobCost ( jobID, expenses, profit, ... , refID)
Where:
Employee is my personnel roster matching names to numeric employee IDs and stats (salary, et al) ;
JobHours is a list of employee participation -- whenever an employee spends time on a job, this table has a line that shows their ID, the job ID, hours worked, and a few other things;
JobCost is a daily record of jobs. One entry in this table refers to the activity for a single job on a single day. Additionally, each entry gets a system generated unique ID (since neither jobID nor date is unique) to relate to JobHours (resulting in a list of who worked on a particular job on a particular day).
I have a form showing records from JobCost. For each record, I can see in a portal, showing records from JobHours, who worked on that job on that day.
Now, the issue.
In my portal, I want to have a drop-down list of employee names pulled from a value list to create records in JobHours with the following criteria:
1) I need it to be a drop-down rather than a pop-up so it will respond to auto-fill from the keyboard. A drop-down will show the secondary value (employee name) from a value list while dropped down, and will respond properly to keyboard autocomplete on the secondary value, but once you've made your selection, it only displays the primary value (employee ID).
2) I need it to display names, not IDs, at all times. The pop-up does this perfectly. However, it doesn't seem to respond to the keyboard for typing autocompletes.
3) I need to store the numeric ID rather than the name.
I know how to satisfy any two of these criteria at once, but that's all. The whole database is working beautifully otherwise. Is this behavior possible?
One common technique is to use two fields, one directly on top of the other.
On the bottom, put your JobHours::EmpID field. Set it up as the drop-down list with the value list that you've specified.
On top of the JobHours::EmpID field put the related Employee::EmpName field. Set the field so that it cannot be entered in browse or find mode.
Now your users will see the Employee Name, but when they click that click will go through the top field and into the Employee ID field where they will choose the name from the value list.
pft's solution is one that I have long used, but I do still find it inelegant because the user still sees an existing id number in the field when changing the value.
If the type-ahead is important, I would use the popup menu. Once the menu has been activated either by tabbing into it or by clicking into it, the user is able to type from the keyboard and the selection will change based on what's entered.
I came to this thread looking for a solution to this same issue (allowing the user to pick from a list, show their choice, but store a related value instead). For example, choose a plant species name from a dropdown, show the plant species name in the dropdown field, but have it store the taxonomic serial number (TSN; which is more likely to stay the same over the years). This is easy to do in MS Access, but took a litlte more messing around to do it in FMP12.
How I solved it:
I created two fields in the table that would be storing the values: Plant_TSN and Plant_SciName. A relationship must exist between the values in these two fields. In my case, I store a SciName for each TSN in a lookup table. I then created two fields in my layout, one for each new field.
For the value you wish to store (ex. Plant_TSN):
Make the corresponding layout field a dropdown and include the show/hide arrow. Edit the value list you will populate the dropdown with to show the second (reader friendly) column but store the first column value. In the layout shrink the field to only show the arrow.
For the field you wish the user to see (ex. Plant_SciName):
make the other layout field a Edit Box and prevent field entry in either Browse or Find mode. But it up against the dropdown arrow created in the previous step to make what looks like one field.
Finally, back in the first field (arrow-only drop down) write a script to push the user friendly number (Plant_SciName) to the edit box when the user-ugly (Plant_TSN) value is picked in the drop down. I used the OnObjectSave script trigger of the dropdown formatted field. Script should be something along the lines of 1) Freeze window, 2) Go to Related Record (based on relationship in lookup table 3) Set Field (i.e. the edit box) and 4) GotoLayout[original] to offset the Freeze.
Probably not an entirely clear explanation, but I bet you will get it on your third read through! I would have posted a screenshot, but I apparently need 10 "reputation points".
Cheers.

Duplicate ALL Filemaker Portal Rows only if valid

I would like to create a script that copies only valid Portal Rows from a Record.
ie. Sample Request is the main record
Sample colours are the relationship (SampleNumberID)
ie. Colour 1, Colour 2, Colour 3, Colour 4
I can get this for work if it has all 4 rows entered, however if there is ok 2 colour entries It will copy it twice to fill up 4 portals every time.
Any help would be great, Thanks.
Image of Current Script working for 4 colour ways however if only 1 colour is entered it will copy the same colour 4 times.
http://www.coquet.com.au/wp-content/Script.png
Here is how I would do it, I would go to the related records, using the portal row relationship. Go to the first record, loop through them all and duplicate each one and then return to the parent record. So it would look something like this:
Go to Related Record [Show only related records; From table: "Sample Request"]
Go to Record/Request/Page [First]
Loop
Duplicate Record/Request []
Set Field [ByCoulor::StyleNumberID; GetNextSerialValue(Get(FileName); "Sample Request")]
Go to Record/Request/Page [Next; Exit after last]
End Loop
Go to Layout [original layout]
As a side note, it looks like you might to set the field StyleNumberID as an Auto-Enter serial number, so you don't have to manually set it.