Infopath Repeating Table Replacing Looked Up Values in all Rows; Values Based on Two Seperate Fields - forms

Here's the thought process and believe it or not I had it working and then it broke, now I am not sure why or how to fix it.
I have a secondary data source that is housed in a SharePoint list that contains billing rates for various tiers depending on the customer.
When you initially select a Tier and then the subsequent Positions under the daily billing area all is fine and dandy and values look up as they should.
However as is often the case someone will input the wrong Tier for the billing sheet and it would need to be changed to reflect the actual Tier. When this happens InfoPath is grabbing the value from the first row for the lookup and making it the value for all the position rate fields in the repeating table.
You can change them back, by selecting a different position and going back to the original position, however that is another step.
Seriously, this is the last bit for me to sort out before I can put this project behind me. I've included some screenshots of the groups and how they are laid out and the rules I have setup.
[Rules for Rate Tier field](https://i.stack.imgur.com/DO7e4.png)
[Rules for Position field](https://i.stack.imgur.com/JF8bh.png)
[Groups and Fields layout](https://i.stack.imgur.com/7etEq.png)
[Example of issue I am having](https://i.stack.imgur.com/aKD3t.gif)
I've tried everything from filtering the rate returned by the Position in the secondary source matching to the Position in the form which is activated conditionally when the Rate Tier equals a specific Tier. I've tried eval which I am not familiar with so I either got true or false but it never returned field contents.

Related

Microsoft Access Form combo boxes and calculations

I have a question regarding a data entry form for project pricing estimates I am currently building.
To give you some context: The form will be used to enter data and complete calculations. It will replace an excel spreadsheet comprising of 59 columns, 1-15 rows (it varies by requirements) per project estimate. Average number of projects is 50-60 per year saved in respective customer folders. If there is an update to the estimate, a new version of the spreadsheet is created and saved in the respective customer folder. Hence, in certain scenarios, there are can be up to 10 versions saved per customer per project.
I am seeking to create a form-table combination for each of the customers: hence 10-15 forms with the same structure. Currently, I am only creating one form and table combination as a test. The table designed to replace the spreadsheet will use a total of 30 auto number foreign keys to store information. To be user friendly, I am using combo boxes in my form, where the user types in text but is stored as a foreign key in the table.
On top of this, I need to include calculations. For example, if the user selects certain options from my combo boxes, this will result in a calculated answer in an adjoining form field. Part of the calculated answer will use data in a linked table from another access database. Based on the options selected in the form combo boxes, the database will scan specific columns in the linked table to find matching entries to the selected combo box options. If a match exists, a price is extracted from that linked table. So say the combo box options selected are origin Miami and destination Salt Lake City, the database will scan for those 2 entries in the linked table. If that entry combination is found in the linked table, this price is to be used in the calculation. This price will then be multiplied by two other components entered by the user in the form, resulting in the calculated answer.
My questions:
Regarding the calculation example I gave above, can the above scenario be realistically accomplished in Microsoft Access? If so I am assuming I have to use VBA and/or Macros to do so?
a. If so, is it suitable to use my data entry form to complete it? Or is there an alternate way to achieve this result?
Will 30 combo boxes combined with such calculations have a significant impact on the speed of my form and database, especially as more data is added to the form and given that 10-15 forms will use the same structure? I have thus far included half of the combo boxes in 1 form, completed 1 test entry and I find that occasionally there is a slight lag when opening the form.
a. If it will impact my form's performance, what are my options/other form controls I can use to minimize lag and maximize speed?
Many thanks in advance!

Getting ID fields from the primary table into the linked table via Form

As an amateur coder for some years I have generally used sub forms when dealing with linked tables to make the transfer of ID field from primary to sub nice and simple...
However in my latest project the main form is a continuous form with a list of delivery runs (Date, RunName, RunCompleted) etc... Linked to this primary table is a delivery list containing (SKU of product, Qty etc...). I use a simple Relationship between the two tables.
Now, On the main (RUNS) form at the end of each row is a button that opens the DELIVERIES form and displays all records with matching RUNID
This is fine for displaying pre-existing data but when I want to add new records I have been using the following code attached to the OnCurrent event:
Me.RunID = DLookup("[RunID]", "tbl_BCCRuns", "RunID = " & Forms![frm_BCC_Runs_list]![RunID])
I have also used:
Forms![frm_BCC_Deliveries].Controls![RunID] = Forms![tbl_BCCRuns].Controls![RunID]
(Note: above done from memory and exact code may be incorrect but that's not the problem at hand)
Now... Both these options give me what I need however...
I find that as I am working on the database, or if you open certain forms in the right order (a bug I need to identify and fix clearly) you can open the DELIVERIES form without the filter (to view all deliveries for arguments sake) and the top entry (usually the oldest record) suddenly adopts the RUNID of the selected record back in the main form.
Now, my question is this, and the answer may be a simple "no" and that's fine, I'll move on...
Is there a better way, a way I am not familiar with or just don't know about due to my inconsistent Access progress, to transfer ID's to a form without risking contamination from improper use? Or do I just have to bite the bullet and make sure that there is just no possible way for that to happen?
In effort to alleviate the issue, I have created a Display Only form for viewing the deliveries but there are still times when I need to access the live historical data to modify other fields without wanting to modify the RUNID.
Any pointers greatly appreciated...
Since you only want to pull the RunID if the form is on a new record row, do a check to verify this is a new record.
If Me.NewRecord Then
Me.RunID = DLookup("[RunID]", "tbl_BCCRuns", "RunID = " & Forms![frm_BCC_Runs_list]![RunID])
End If
Could also consider a technique to synchronize parent and child forms when both are subforms on a main form (the main form does not have to be bound) https://www.fmsinc.com/MicrosoftAccess/Forms/Synchronize/LinkedSubforms.asp

Access: Forms, Subforms and Queries

According to the searching I've done over the past couple of days, what I'm trying to achieve should be fairly straightforward but nothing that I've found has solved my problems. This is my first time at using Access, or SQL at all. Apologies in advance for the length of the question.
Essentially I need to pick up a value from one table and multiply it by another in the another table, and then store the result in the second table, via forms and subforms.
The Problem:
I'm attempting to create a database of projects, part of which is a quotation tool. The database has several tables covering all the required inputs for our project managers, most of which are linked to the PKs of their parent tables.
My current attempt has a form (frmJobDetails) giving the details of the each project (linked to tblJobs). This form has two subforms:
frmJobRolesSubform details who's working on the project in what role ( and, notably, their sale rate.
frmJobProcessesSubform details the tasks, who's allocated to which task and the estimated number of hours to complete.
Both subforms link to their own tables (tblJobs_Roles and tblJobs_Processes respectively).
frmJobProcessesSubform obtains the people working on the project and their roles from frmJobRolesSubform so the manager can allocate a person to a task on frmJobProcessesSubform. This is done via a combobox: cboRole.
So far, so good.
I'm needing to obtain the sale rate of the person working on the given task so that I can calculate the cost of the task. Specifically, I'd like a field on the subform to calculate the cost of the task and then store it in tblJobs_Processes.
My Attempts
I've attempted to build a query (qryProcessCost) that calls cboRole, either as an expression in the Field cell or in the Criteria cell ([Forms]![frmJobsProcessesSubform]![cboRole]).
I'm aware this can't successfully when the form isn't active, but I'm getting Access' request for input for [Forms]![frmJobsProcessesSubform]![cboRole] when selecting from the subform. The query runs successfully when example values are hardcoded into the query. The query should, obviously, only return a single value.
I've tried setting the ControlSource of a textbox to [qryProcessCost]![dblProcessCost] (where dblProcessCost is the calculated field), but this can't then write to the table (as far as I can deduce). Also, I get a #Name? error in the cell and I can't seem to get to the bottom of that.
I've tried setting the RecordSource property of a combobox to SELECT [qryProcessCost]![dblProcessCost] FROM [qryProcessCost], and the ControlSource to the relevant field of the table. While this would be a clunky solution, it actually doesn't work anyway as it fails to pick up the value of [Forms]![frmJobsProcessesSubform]![cboRole].
I've tried using an intermediate textbox to determine what value cboRole is passing, and I'm happy with that - the primary key of the role assigned in frmJobsRolesSubform.
The Question:
I'm guessing that I'm probably going to have to resort to VBA at this point to get what I want but I'm unfamiliar with the Access VBA structures (though I've used Excel VBA a fair bit).
Anyone got any ideas, hints, suggestions or pointers?
Cheers in advance,
Aaron
In case anyone else has a similar problem, I've posted my complete solution below:
I implemented Gene's correction to my references, which provided something, but the query wouldn't update when the fields on the form were changed. As I noted in the question, I also really wanted it to be a text box rather than a combo box for usability reasons but wasn't sure how to have a Record Source and Control Source for a text box.
I ended up going round in circles, via VBA and macros and several types of error and happened upon a suggestion to use a DLookUp here. I hadn't been able to get them to work for this particular problem before, but I managed to make it work this time. Specifically, I put the DLookUp in the following macro:
SetProperty
Control Name txtBudgetCost
Property Value
Value =DLookUp("[dblCostRate]","[tblJobs_Roles]","[pkJobs_RoleID]="[cboRole])*[txtBudg‌​etHours]
This macro was used for the After Update event of the relevant fields on the subform.
Setting the value property of a field to a DLookUp meant that I could set the Control Source property of a the text box txtBudgetCost to the relevant field in the table, to obtain the desired behaviour.
Both cboRole and txtBudgetHours are fields on the same subform as the field txtBudgetCost.
The only problem with this solution is that, when the subform is viewed in the Datasheet view, a #Name? error is given for the new record row. I probably just need to enter some error handling somewhere, though I haven't given much thought for what it should be just yet.
Cheers,
Aaron

Filemaker GetSummary from related table

I'm been using FM for the first time and have a need to use Get Summary on a financial information table. This generates various summaries of different income by customer, year and type. The layout generated from this table is good. The use of Get Summary allows me to do math with the various results, whereas sub summary totals by income type (as far as I know) cannot be added and divided by each other.
The problem I'm facing is that I wish now to create a layout based on customers and include some of the Get Summary detail from the financial table. Because my new layout is based on customers, I understand I cannot use Get Summary from financial as either a related field or in a portal.
The end game is simply to scroll through customer records, one after the other, and have key financial information show on their 'home' screen if you will, for years and type.
Any help gratefully appreciated. Thanks
I understand I cannot use Get Summary from financial as either a
related field or in a portal.
No, that's not quite correct. The GetSummary() function returns the sub-summary value by breakfield - if records are sorted by breakfield. Thus if the portal (or the underlying relationship) sorts the related records by type, you will see sub-summary values in the portal. However, you won't be able to see only sub-summary values, since a portal has no sub-summary parts.
There are other ways to show summarized related data. If you don't have (and don't expect to have) a large amount of records, considering filtering a (one-row) portal to show only a specific type of related records, then place the summary field inside it. Of course, this assumes the types are known in advance and unchanging.

Last Updated Date: Antipattern?

I keep seeing questions floating through that make reference to a column in a database table named something like DateLastUpdated. I don't get it.
The only companion field I've ever seen is LastUpdateUserId or such. There's never an indicator about why the update took place; or even what the update was.
On top of that, this field is sometimes written from within a trigger, where even less context is available.
It certainly doesn't even come close to being an audit trail; so that can't be the justification. And if there is and audit trail somewhere in a log or whatever, this field would be redundant.
What am I missing? Why is this pattern so popular?
Such a field can be used to detect whether there are conflicting edits made by different processes. When you retrieve a record from the database, you get the previous DateLastUpdated field. After making changes to other fields, you submit the record back to the database layer. The database layer checks that the DateLastUpdated you submit matches the one still in the database. If it matches, then the update is performed (and DateLastUpdated is updated to the current time). However, if it does not match, then some other process has changed the record in the meantime and the current update can be aborted.
It depends on the exact circumstance, but a timestamp like that can be very useful for autogenerated data - you can figure out if something needs to be recalculated if a depedency has changed later on (this is how build systems calculate which files need to be recompiled).
Also, many websites will have data marking "Last changed" on a page, particularly news sites that may edit content. The exact reason isn't necessary (and there likely exist backups in case an audit trail is really necessary), but this data needs to be visible to the end user.
These sorts of things are typically used for business applications where user action is required to initiate the update. Typically, there will be some kind of business app (eg a CRM desktop application) and for most updates there tends to be only one way of making the update.
If you're looking at address data, that was done through the "Maintain Address" screen, etc.
Such database auditing is there to augment business-level auditing, not to replace it. Call centres will sometimes (or always in the case of financial services providers in Australia, as one example) record phone calls. That's part of the audit trail too but doesn't tend to be part of the IT solution as far as the desktop application (and related infrastructure) goes, although that is by no means a hard and fast rule.
Call centre staff will also typically have some sort of "Notes" or "Log" functionality where they can type freeform text as to why the customer called and what action was taken so the next operator can pick up where they left off when the customer rings back.
Triggers will often be used to record exactly what was changed (eg writing the old record to an audit table). The purpose of all this is that with all the information (the notes, recorded call, database audit trail and logs) the previous state of the data can be reconstructed as can the resulting action. This may be to find/resolve bugs in the system or simply as a conflict resolution process with the customer.
It is certainly popular - rails for example has a shorthand for it, as well as a creation timestamp (:timestamps).
At the application level it's very useful, as the same pattern is very common in views - look at the questions here for example (answered 56 secs ago, etc).
It can also be used retrospectively in reporting to generate stats (e.g. what is the growth curve of the number of records in the DB).
there are a couple of scenarios
Let's say you have an address table for your customers
you have your CRM app, the customer calls that his address has changed a month ago, with the LastUpdate column you can see that this row for this customer hasn't been touched in 4 months
usually you use triggers to populate a history table so that you can see all the other history, if you see that the creationdate and updated date are the same there is no point hitting the history table since you won't find anything
you calculate indexes (stock market), you can easily see that it was recalculated just by looking at this column
there are 2 DB servers, by comparing the date column you can find out if all the changes have been replicated or not etc etc ect
This is also very useful if you have to send feeds out to clients that are delta feeds, that is only the records that have been changed or inserted since the data of the last feed are sent.