MS Access - Pass-through value from two Forms - forms

Background:
I have three forms for generating a new request, and here's why:
Form 1: frmRequests - Create New Request (Data is tblRequests)
Everything works here, fine - the buttons are:
Button 1 - Save and Exit - Adds the new request to the tblRequests table with status of 'Pending'
Button 2 - Save and Finish Later - Does the same as above with status of 'Incomplete'
Form 2: frmIncRequest - Edit Existing Request (Data is qryIncReq - which filters only on Status = "Incomplete") so they can continue the request. I have other code that opens the form to a select project number from a combo box on the Main Menu.
Form 2 is basically a copy of Form 1, but the Data Source is different.
Form 2 is opened based on a selection from a combo box using the qryIncReq query
Each of those forms has an option for Multiple Requests if there are other work orders related to one project. A selection button opens the Multiple Requests form.
The Project Number field has to match the Project Number on Form 1 or Form 2 depending on which one is open at the time.
From 3: Multiple Requests:
On the Project Number field I have the following:
Property Sheet > Data tab > Default Value = [Forms]![frmRequests]![txtProjectNumber] and it works wonderfully, and if I change it to the frmIncRequest too.
My question is:
Is there a way to change this to look at the form depending on which one is open? or
Do I have to create another Multiple Requests form to finish the Incomplete Requests?
Any ideas?
Thanks in advance!

Related

Cause one textbox to validate other textboxes/dropdowns

I am trying to make a form textbox in PowerShell in which I can paste data into the first textbox and have it auto populate to several other fields when I hit Tab.
I managed to get that part working fine, but the various validation steps that those other fields normally have don't work when filled out in this way.
Here's a sample of what I am talking about:
$InputTextBox.Add_Validating(CODE SEGMENT 1)
$DescriptionTextBox.Add_Validating(CODE SEGMENT 2)
$SplitComboBox.Add_Validating(CODE SEGMENT 3)
Is there anything I can put in CODE SEGMENT 1 to trigger CODE SEGMENT 2 and CODE SEGMENT 3 to run as well? Is there another way to do this with a different approach?
Edit:
When I tab out of $inputTextBox, it splits up the input there and distributes it to the other fields with $DescriptionTextBox.Text = $Description and $SplitComboBox.SelectedItem = $Split.
When that is done though, the values entered do not trigger the contents of Add_Validating() to run.

how to recover the (context) information of the original selected records before executing the wizard?

I'm using OpenERP web 6.1.
step1: I have form 1 - button 1 opening form2.
step2: From form 2 button 2 is opening form 3.
step3: from form 3 (where users are selecting some values) I return to form 2 using the values selected in form 3.
The issue is how can i use the initial context that I had on step2 (i need id and values from form 1).
In step 3 I'm using the context['active_ids'] but when returning to form2 I'm not able to find form1 id in context.
Related is the following but I don't know how to do it:
https://answers.launchpad.net/openobject-server/+question/116262
I got it working!
Form 2 xml file in declaring action i have the context:
<field name="context">{'res_id': active_ids}</field>
And in form 3 .py file i have:
context.update({'res1_id': context['active_ids']})
Now in the py file of form 2 wizard i'm able to use:
context['res_id']
to get the id of form 1.
Many thanks!

Multi-step form with user-input and external web-service

I am building a Booking model in Rails 3.2.3 where a user steps through several form-screens of choices. If the form exactly mirrored the underlying model I know I could use a gem (e.g. Wicked gem) to build a multi-step form. The issue I am having is that on one of the form-screens there are multiple options for the user and within each of those options there are multiple options coming from an external web-service. In other words, on step 2 of the multi-step process, the form presents the user with many options of Rates from our database and for each Rate we have multiple additional options from the web-service. So a user would need to choose one of the options from the web-service (radio buttons) and then make a selection of their Rate of choice. This is then repeated multiple times on this page (although the user can only choose one radio-button option from the web-service and one Rate).
Where I am unsure of best practice is that I can display the multiple options from the web-service as radio buttons but there is a Hash of values associated with each of those options and hence with each of those radio buttons.
So, the question is, should I be attempting to pass that Hash as a param to the next step of the form process or should I be making that into an object and passing that or something else entirely!
I know this is a long explanation but I feel it's a critical point in the design of this workflow and I want to get it right.
Many thanks in advance,
J.
EDIT
Thinking it through again, the initial problem is how to represent a series of radio buttons when each radio button represents many values as opposed to say an id (in this instance each radio button represents a hash of values from the external web-service). Should the hash be made into an object and this passed instead - something along those lines?
I figured this out. On inspecting the "hash" coming back from the external web-service, I noticed that date fields were not in quotes, e.g.
:departs=>Wed, 21 Aug 2013 10:40:00 +0000
whereas all the other fields were in quotes. This made me a little suspicious. So in the end I used to_json on the returned hash:
response_hash_from_webservice = data.to_json
In the form I then used:
JSON.parse(response_hash_from_webservice).each do |nested_item|
# Access elements like so
... nested_item['company_name'] etc ...
end
However I needed to post this nested_item through to a next step of the form (as a radio button) and it only worked by again using to_json.
<%= radio_button_tag 'nested_item', nested_item.to_json %>
I could then post this value or put it in the session and on the following form page use:
require 'json'
hash = JSON.parse session[:nested_item]
And then access the values as normal:
<%= nested_item['company_name'] %>

Requery subform (1) after adding a new subform (1) record via pop-up subform (2) - Access 2007

I have a form with two subforms (1 and 2). Subform 1 stores the data continously for account breakdowns. Using a pop-up subform (subform 2), the user enters data to change or update the account breakdown stored on subform 1. On submit, the information is stored in the sub-table linked to subform 1, but the data does not refresh and add the new information in a new record in subform 1 unless I manually click the refresh all button in the home tab.
So far, I have tried the following code on form_afterupdate of subform 2, which does requery subform 1 automatically but creates a run-time error (2450) when the main form is closed:
Private Sub Form_AfterUpdate()
On Error GoTo Err_Form_AfterUpdate
Forms!frmSpendPlan!frmSpendPlanSub.Form.Requery
Exit_Form_AfterUpdate:
Exit Sub
Err_Form_AfterUpdate:
MsgBox Err.Description
Resume Exit_Form_AfterUpdate
End Sub
If anyone has a way to automatically requery subform 1 data once subform 2 is submitted without creating an error please let me know, I appreciate any help you can provide.
Thanks!
I have the same problem as you sometimes! The form doesn't refresh properly.
Method 1
try this line of code instead of the current requery code. It shouldn't give you an error but may still not work due to bugs...
Form_frmSpendPlanSub.Requery
I use this format to reference across forms and it works well usually.
Method 2
1) What you can try is in design view click on the form that is doing the "After_Update"
2) Right-Click on the form and click "BUILD EVENT.." and select "Expression Builder"
In expression builder you can see exactly how the form you are in links to the form you want to get to and what you want to do...
So you would navigate yourself by going to FORMS--> Loaded Forms--> frmSpendPlanSub and then from the list you can double click on " "
This will get you referenced to the form you want to affect.
Then all you have to do is copy the code that it gives you in the box above into your VBA code and then reference what you want to do...
E.g.
Forms![frmMainForm]![frmSecondForm].Form![frmThirdForm].Form.Requery
Anyway hope that helps...

Zend_Form : Adding fields in sub-forms on user's click

I'm having a zend form - comprised of a number of zend - sub forms, where the user is creating a new question (its a content management system).
In one of the subforms, the user can click on a button to add more textfields, like this:
[----------]
[----------]
[click to add more]
which should give
[----------]
[----------]
[----------]
[click to add more]
I'm trying to set a flag in the sub form in question - or set a count on how many times the button has been clicked, to add that many total fields to the subform - but its simply not working.
I tried using a static count variable - but the value doesnt get incremented at all.
Any thoughts on how to do this in a Zend-subform within a zend form?
I'll definitely update if I hit a solution.
Thanks!
I used Sessions to store the click.
i tried doing this with javascript but within the subform it was not working.
if i simply have such a situation where there is just 1 form (no subforms), the javascript solution works fine.
effectively, just increment the counter by one onclick.
with sessions, or some other global variable, simply do the same - increment the counter, and unset that var when the form is submitted.
so - when u come back to the form, the previous session var value is not retained.