Access: the way the form is opened populates the combo box differently - forms

Not sure if this can be done:
Basically I have created a database which logs interventions for a client (i.e phone calls, appointments, documents etc etc) the current project workers log these interventions as they happen from their live caseload. appointments have their own form, phone calls have their own form etc.
Now I have been asked to do the same for admin so they can log historical data for the last year or so, the thing is the selection data of the combo box is different (ie. old staff, services we do not work with anymore)
Is it possible to have a form populate differently depending on how you open it, ie the admin way will populate all the historic selections, and the project worker (live way) will populate all today's relevant information? I don't want to have to duplicate loads of forms that basically do the same thing.

Easy,
just change the source data for the combo box depending on who opens the form
use a variable or a checkbox or a UserID or something to tell who the user is then:
if varUser = 'boss' then
combobox.datasource = 'Select * from services where historical = 1'
else
combobox.datasource = 'Select * from services where historical = 0'
end

Related

MS-Access: How to create form where user can add results (tblResults) to a tests (tblTests)?

I am creating a database that contains Product information (tblProductInfo), a list of test methods (tblTests), and the results that the product gets (tblResults).
I'm adding forms so that a user can enter the results of a previous or new product. This information will be added once all the testing for that product is done. So, I would like to be able to show a list of the tests from tblTests, and have the user enter the results in a text box of some sort displayed directly next to the tests. I can't figure out a way to do so, where it will then save all the results that the user entered.
I have created a form with a subform, where the subform shows the 2 columns (tests and results) and when I change it to allow DataEntry, it gets rid of all the test names. I need it to keep the test names displayed, but allow entry in the results column.
Any ideas?
Below is a screenshot of an example of what I would like, although I need the Results column to be empty.
Create a continuous subform with only the tblresults as the recordsource, and for the header or each field of results use the related test as the label is how I would do it. Set allow additions to yes, allow edits to no allow deletions to no.

MS Access 2003 findfirst method doesnt work in Load() event of form

After a few days of frustration, I have decided to present this issue here for resolution. Searches through countless forums and help sites have not presented any similar issue. The following details the problem with a FindFirst method in MS Access 2003:
Tables and Forms: Customer Info Table > Service Details Table as a one-to-many relationship with referential integrity and cascading updates enabled (there may be more than one service detail for each customer). A search form allows user to select ‘customer’ and ‘service provider’ (a field in table Service Details) sending that information to open a main form/subform to enter service data related to ‘customer’ using ‘service provider’ (text string) as criteria. There may be more than one ‘service provider’ per ‘customer’ (i.e. each Service Detail entry may have a different ‘service provider’ for the same ‘customer’).
Objective: The main form (with subform, both based on select queries) should open to the specified record/subrecord.
Current Method: A combo box on the main form (not the search form) allows user to select appropriate ‘service provider’ using the FindFirst method (combo box created by wizard). This works but not what is intended. The ‘service provider’ criteria is initially selected in the search form and passed into the main form (as a global variable for now), so the combo box selection on the main form becomes redundant and could cause confusion for the user (they could accidentally enter data for the wrong service details).
Problem: I assumed copying the code from the AfterUpdate() event of the combo box to the Load() event of the main form would be adequate, but it does nothing, no errors, just loads the first available Service Details record instead of the selected one using ‘service provider’ as criteria.
Tests: I have inserted message boxes to check the criteria value for the ‘service provider’ selected, and everything seems ok, both in and out of the FindFirst method inserted in the Load() event of the main form. I have tried a DLookup(), DoCmd.Findrecord and setting the default of the combo box to the criteria passed from the search form, but still only the first ‘service provider’ record is displayed, instead of the one selected in the search form.
Code:
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Service Provider] = '" & [g_serviceProvider] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
This produces no errors, and hovering over the g_serviceProvider variable with the mouse in debug mode shows the correct string value. This code works perfectly in the AfterUpdate() event of the combo box, but does nothing when inserted into the Load() event of the form, even though the values are indeed passed (checked using message boxes to display data at each stage of the execution).
I am at a loss of why this only works for the combo box but not in the Load() event of the form. I suspect the problem is in the recordsource of the form (select query), as the recordsource of the combo box uses a SELECT expression based on the same query as the form. I have had no success with coding the recordsource to use with the FindFirst method within the Load() event, as that produces errors (cannot find any relevant examples to work from). Any ideas? Thanks in advance.
Ok, I finally figured it out. The actual problem was the form loading the Current() event multiple times when opening the form to a specific record. This was happening on pretty much every form where an existing record is being displayed. It seems to be an artifact of the form opening and record selection of MS Access 2003 (don't know about newer versions, but I have read several other posts concerning this issue).
There is a dirty work around, by using a count of the number of times the Current() event runs when a form is opened. I have found that for a "virgin" form (blank form ready to accept input with blank record source (table)) the Current() only runs one time. If there is any existing records, but the form is blank ready to input a new record, the Current() will run twice. When displaying a record that already exists that must populate a form, the Current() will run three times before all of the data loads enough to make the selection through coding rather than through a combo box (which loads with the control). Subform Current() seems to run one more time than the parent form.
To check to see if and how many times any event occurs, insert a simple message box in the suspected block of the form's VBA code.
Creating a simple counter, coded in the Current() event block of the main form, solved the problem.

MS Access Form and Tables

I have a specific question regarding the utilization of three tables in a database. Table 1 is called Personnel, and lists the names of the staff.
Tables 2 and 3 are identical, just listing two different types of overtime (long and short), along with the hours of the OT, Date of the OT, and Assigned to/Picked fields that are empty.
Here is the idea, I just dont know how to implement it. I would like to create a form for people to enter their OT picks, then automatically move to the next person on the list. So Rich Riphon, as an example, would be up first, would click on the link I would send, and a form would open up, showing his name, populated by the first table, and showing two drop down menus, populated from the Long OT and Short OT tables. He would select one from each (or None, which would be a option) and Submit it.
The form action would be to place his name in the Assigned field for the OT he picked, and place a Yes in the Picked field.
When the next person in the list opens the form, it has moved down to number 2 on the Personnel list, Cheryl Peterson, and shows her the remaining OT selections (excluding those that have a Yes in the Picked column).
Any suggestions or comments or better ways to do this would be appreciated.
First, I don't think ms access would be able to (easily) kick off the process based on a hyperlink. You may be able to do something by passing a macro name to a cmd prompt but it would take some mastery to get it working properly. Could you instead create a login form to get the current user? If you do that you don't really need to display the personnel list, just keep track of who has not yet responded to the OT request. Essentially at that point all you would need on your form is a listing of the available OT and a button that creates the assignment. Also it may be easier (and a better design) to only have one table for the OT listings and add a column for the type of overtime (long/short).
What if Cheryl isn't the 2nd person to get the form? Your concept goes out the window.
Instead, I would keep a table of all user names, and their security level. managers can see everything, individual users can only see their record. This would be done by using a query behind the OT Picks form, and either filtering by the current user or not filtering at all. I have done many of these types of "user control" databases and they all have worked well.
As for the actual OT tracking, I agree with Steve's post in that it should be done in one table This would be the preferred method of a concept referred to as "normalizing data". You really want to store as little data as possible to keep the size of your database down. As an example, your Login table would have the following fields:
UserID
FirstName
LastName
SecurityLevel
Address1
Address2
City
State
Phone
Etc... (whatever relevant info pertains to that person)
Your OT table would look like this:
UserID
OTDate
OTHours
OTType
Etc... (whatever else is relevant to OT)
You would then join those 2 tables on the UserID fields in both tables any time you needed to write a query to report OT hours or whatever.

InfoPath 2010: Mirror data from a Secondary Data Source

Goal: Pull data from a SharePoint 2010 List using a WEB ENABLED form. Then, from the repeating table that contains the secondary data, extract only the desired data and mirror it in my main form fields. The extracted data would then be modified, and submitted to another sharepoint list using Nintex Workflows or, if the IT department smiles upon this project, a database.
What I've Tried: Created a field, named "TEST_CyS", in a repeating group, named "TEST", in my main form fields to store the mirrored data. This field has a default value of:
xdXDocument:GetDOM("REMOVED")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[(count(../preceding-sibling::*[local-name() = "TEST"]) + 1)]/d:Cy_Statement
This is refreshed when the form updates.
If I set the default value to count(../preceding-sibling::*[local-name() = "TEST"]) + 1 it accurately counts each inserted group.
if I set the default value to xdXDocument:GetDOM("REMOVED")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[<INT>])]/d:Cy_Statement where <INT> is any whole value between 1 and n then the field will display the correct information, for the secondary data field whose index is referenced.
It's when I combine the two that things fall apart.
Main Data Tree:
Secondary Data Tree:
Assumptions: I am guessing that the preceding-sibling::*[local-name() = "TEST"] axis is not returning a value due to the fact that it's being called along with the GetDOM() method. I've tried to point the preceding-sibling back to the correct group in the Main form fields, but then I felt silly for trying that as it wouldn't know where to start counting AND infopath presented me with an error:
Function 'GetDOM' did not return a value, or it returned a value that cannot be converted to an XSL data type.
Summary: Is this a lost cause without code or purchasing some "plugin" for Infopath like qRules? The IT department will not budge on allowing Forms with code in them to be run on the SharePoint site, and the requirements placed on the form state that it must be a web enabled form to be filled out in SharePoint.
Edit: We also do not have access to VSTA, and the possibility of having it installed is very, very slim.
Is there an alternative method I could use to pull this off?
SharePoint admins don't need to be involved if the InfoPath form uses code, so long as it is limited to the SharePoint 2010 sandbox APIs.

How to create update process for single entry form in APEX 4.1

I'm new to APEX. I am sure this solution might be available, but was unable to find a proper answer anywhere.
Here is the case scenario: (Provide user a capability to update a particular report row).
Page 1 has report A in which there is a particular column say column B which has links to all its row, by clicking on one particular row user navigates to the new page (Page2).
Page 2 has single entry form in region one which has list of items (around 10) and on region 2 of the same page (page 2) it has a tabular form.
Some of the items in region 1 of page 2 are populated based on the information from page 1 report details. Some items have LOVs and some item user can add information.
The tabular form in region 2 of page 2 is generated based on line item id which can be edited by the user. The tabular form is associated to one table only.
There are two buttons on the page, cancel button takes back to the report page, whereas the save button will save the data to the database tables. The single form items will update 2 tables, whereas tabular form will update one tables.
How the process needs to be establish for updating the underlying tables through apex.
Right now Tabular form has MRU update built in process(but I am not sure can I use this process in coordination with single entry form or it is better to create a separate process which handles both updates)
Can anybody give me an idea how this can be accomplished, or a link where such process has been explained?
You will need to manually create plsql processes to process the submitted values and apply them to your tables. You can not use the built-in row processing to do this: you can not define 2 per page. (That makes sense because you can not indicate which column maps to which table. You can only define "database column" as source for an item. This means that even if you were to have 2 processes, these columns would be attempted to process on both processes, which would lead to errors.)
Take a look at this post for some ideas on how to set the processes up: https://stackoverflow.com/a/7877933/814048
if :P42_ORDER_STATUS in ('IP','OW') then
begin
FOR I in 1..APEX_APPLICATION.G_F01.COUNT LOOP
update sales_mst set ORDER_STATUS = 'DR'
where id = to_number(apex_application.g_f01(i));
end loop;
end;
end if;