saving temporary form on MS Access - ms-access

I am currently working on a database project using MS Access that allows user to submit their applications via forms and these applications get saved on a masterlist table. I am wondering if MS Access has the ability to support features which allows a user to save a form which they have filled, but not officially submitting it yet, and afterwards at their own discretion they can re-enter to submit their forms, which then only gets captured in the masterlist table. Any suggestions to architect this feature are welcome, or any limitations in doing so

Second suggestion Calls for a few preparations, but makes submitting a very simple task:
Assuming table name is masterlist, add to the table a field
Submitted, Boolean value (Yes/No Value), Default Value = False.
Submitting an application will be done by setting this Field to True.
Change masterlist table name to tbl_masterlist, and create a query:
SELECT * FROM tbl_masterlist Submitted = TRUE. Name this query masterlist.
Now masterlist has only submitted applications.
In design view, Change the Form's RecordSource Property to tbl_masterlist. You can filter out undesired applications from the Form, if you wish, using the From's Filter and FilterOn property
add a checkBox field to applications Form, and in the properties window s set it's Name and ControlSource Properties to Submited, and it's Visible property to False.
Finally, add to applications Form a Submit Button, and in it's OnClick event sub add this code: Me.Submited = True.

Related

Google App Maker - autofill textbox depending on dropdown selected option from an external database

What I'm currently doing is that on the Property Editor of my dropdown widget, on the Event Section using the onValueEdit function, I'm trying to create a custom action script which will give a value to my textbox (using widget.root.descendants.NameOfMyTextbox.value) depending on the selected value of my dropdown.
The values of my dropdown are the IDs stored in my MySql database table Process, for example: ID = 1, name = Assembly, manager = George. For the textbox, I would like to get another table field value depending on the selected value of my dropdown through a select statement (like getting the manager value). What kind of app maker queries or functions should be useful in this case?
If your dropdown option binding is #datasources.Process.items then your onValueEdit event simply needs to be:
widget.root.descendants.NameOfMyTextbox.value = newValue.manager;
This would be the only way to set this up however, because this way the options are pointing to your entire record in the Process table and upon selection you can get any other field from that record using newValue.YourField.

Enabling/disabling input into certain fields based on the value of another field

In the data entry form frmlastweeksactivities . When a row has "Gold"or "Silver" or "Bronze" as content in the [“category of activity “] field /column then disable columns/fields[5] & [6]
When a row has "Wood" or "Hay"or "Stubble "as content in the [“category of activity “] field /column then disable columns/fields[8] & [9]
Disable means not allow any data entry in this case turn them red as well would be nice
I am trying to build and expression to use in either the table validation rule properties or in one of the control -txt boxes in the form
EDIT: Solution using table-level validation
The table-level solution will not disable fields, all it will do is validate a record as it is added. If the validation rule fails (evaluates to FALSE) then the user will be presented with a warning message and the update will be cancelled (record not added).
The expression for this should be entered in the Validation Rule Table Property as follows:
IIf((([category]="gold" Or [category]="silver" Or [category]="bronze") And (Len([Field5])>0 Or Len([Field6])>0))
Or (([category]="Wood" Or [category]="stubble" Or [category]="hay") And (Len([Field8])>0 Or Len([Field9])>0))
,False,True)
WARNING: MAKE SURE THE BRACKETS LINE UP AS PER THE EXPRESSION ABOVE!!
The expression is messy but it tests whether either of 2 "fail conditions" you describe are true, namely:
1) Category = gold/silver/bronze AND not null value in Field5/Field6
2) Category = wood/stubble/hay AND not null value in Field8/Field9
Then in the Validation Text property of the Table Property Sheet enter the text you wish to notify the user that their record fails and needs correction before the record can be saved. For example:
"If category is gold/silver/bronze then Field5 and Field6 must be blank, if wood/stubble/hay then Field8 and Field9 blank. Record not saved, please correct before saving."
Here is a screen shot of the table in design view showing the Property Sheet and the 2 properties you need to change.
BETTER: Solution using event-driven validation & control locking within the Form
Given that Access table-level and field-level validation will not do what is required, this solution will utilise event-driven validation on the form. It assumes that you have a form with text box controls called category, Field5, Field6, Field8 and Field9.
With the form in design view, right click on the category field (or press ALT and ENTER simultaneously) to view the properties for the control. In the Property Sheet on the right of the screen click on the Events tab. This displays the possible events for the selected control. See the screenshot below.
You are interested in the After Update event so click in it and then the buttton to the right .... Choosing Code Builder will open up a new VBA module for the form and create an event automatically for you.
Private Sub category_AfterUpdate()
' by default enable all four fields 5/6/8/9
Me.Field5.Enabled = True
Me.Field6.Enabled = True
Me.Field8.Enabled = True
Me.Field9.Enabled = True
' test the value entered by user in the category field and hide fields as required
Select Case Me.category
Case "Gold", "Silver", "Bronze"
' if the user has entered Gold, Silver or Bronze lock Fields 5/6
Me.Field5.Enabled = False
Me.Field6.Enabled = False
Case "Wood", "Stubble", "Hay"
' if the user has entered Gold, Silver or Bronze lock Fields 8/9
Me.Field8.Enabled = False
Me.Field9.Enabled = False
End Select
End Sub
So the code above will ensure that when the user updates the category field the code between Sub and End Sub will run and this code sets the Enabled property for the fields you mentioned as per your logic. This Enabled property if set to False will lock the field from becoming active (accepting the cursor) and will grey it out so users are aware it is disabled.
Finally, when the user moves onto a new record you need to add one more piece of code, to reset the 4 fields to being Enabled. So back in the form in design view, access the properties for the Form object itself either by clicking on a part of the form but NOT on a control. For example click in the form header or footer. When you see the event properties for the form you will see an event named Current. This is the one you need to create an event procedure for in much the same way as above with the ... button. This will take you into the VBA window again and you need to make sure that the following code is entered there:
Private Sub Form_Current()
' by default enable all four fields 5/6/8/9
Me.Field5.Enabled = True
Me.Field6.Enabled = True
Me.Field8.Enabled = True
Me.Field9.Enabled = True
End Sub
This is a screenshot of how the VBA screen should look with all of your code in it.
When you now save and run your form it should behave exactly as you wish. Any questions or issues please comment and I'll try to assist.

Cannot find the referenced form

When I click on the Create New Form button below, I get the following runtime error 2450 dialog box:
When I click on the debug button, it gives me the following:
The main form is called FindClientsNavigation. The "Create New Form" button in the ListOfForms subform is supposed to cause the NavigationSubForm to replace the ListOfForms form with a new CommunicationForm so that the user can enter information from a new form for the Client with the specific Client ID that is available in the txtClientID textbox, which you can see in the top of the FindClientsNavigation form in my first image above.
How do I alter the code above so that it loads a new CommunicationForm in the NavigationSubForm? And how do I get that new CommunicationForm to have the ClientID stored in it, so that submitting the form will allow the form to be saved with reference to the specific ClientID?
The SourceObject needs to be set to a string, which is the name of the form to use:
.SourceObject = "CommunicationForm"
[Note that Forms is the collection of open forms so you cannot use this to refer to a form in the Navigation Pane - unless you know that this form is open.]
You can use the Client ID (on the main form) for this subform, but there are a number of ways to do this and it depends on your specific requirement:
The subform could be based on a query that refers to the textbox (perhaps txtClientID) on the main form. This is one of the simpler approaches.
You could dynamically set the RecordSource for the subform, using a WHERE clause that refers to the Client ID (similar to the above approach).
You could apply a Filter to the subform, so that it only displays the single record for the Client ID.

Link fields of same values in different forms in MS Access

I have an MS access project with four forms one main form (BS&W Data) and three subsequent forms (WellTest form, LoopSamplers Form and WellheadSamples form). The subsequent form will be opened by a command button on the main form based on the value of a specific field (Follow-up Method).
I need to link three fields common between the main form (BS&W Data) and other forms, so by data input in these fields in the main form and then opening the subsequent form finding the same fields populated without re-input.
The three field are (Date, Well Name and Follow-up Method)
Thanks
If you open your form with modal property, you will need to pass parameters as arguments to the form using DoCmd.OpenForm
http://msdn.microsoft.com/en-us/library/office/ff820845.aspx
Otherwise, you can use the following syntax to access directly the control's value and modify it. Of course, it has to be open first to make it work.
Forms("subform_name")("control_name").value = ...

MSAccess 2003 - VBA for passing a value from one form to another

So how can I pass a value from one form to another? For example: The user select's an organization from a list and this opens up a trip form that allows a user to enter various information regarding the trip. At one place I would like to add another little pop up form where they can enter contact information (just a name and phone for POC) of the organization they are visiting.
So when that initial form opened from the selection screen it has two IDs that are simply hidden in text boxes (one being the tripID, and the other being the OrgID), so how do I pass these to the second little pop up form so that the contact information has the relative IDs with it.
Thanks.
The best approach in these cases is not to attempted to pass a bunch of variables. It is too much code, and is inflexible. For example, if you need to pass two values, what happens over the years when that requirement grows to 5 values? Trying to maintain and pass a whole whack of values is too much coding work.
Keep in mind that each form in ms-access is really a class object that you can manipulate in code. So, use a object approach here and you find you not only write less code, but your code will be more clean, more modular, no need for global vars, and code you write can often be re-used between different forms.
Here is how:
In general when one form launches another form in the 2nd form in the forms on-open event (in fact, you can even use as late as the on-load event) you can pick up a reference to the PREVIOUS form object. In other words, you can use a object approach here.
At the forms module level, for form I declare a form object as:
Option Compare Database
Option Explicit
dim frmPrevious as form
Then, in the forms on-load event, we go:
Set frmPrevious = Screen.ActiveForm
Now, any code in our form can FREELY use code, events, even varibles declared as public from that previous form in code.
So, if you want to force a disk write of the previous form, and re-load of data.
frmPrevious.Refresh
If you want to set the ID value, then go:
frmPrevious!ID = some value
And, note that you can even declare form previous as a PUBLIC variable for that form, and thus if you two forms deep, you could go:
frmPrevious.frmPrevious!ID = some value
So, simply declare a forms object in EACH forms code module (or at lest the ones where you need to use values in code). The above means any code has a ready made reference to the previous form object. Functions declared as public in a form will become a METHOD of the form, and can be run like:
frmPrevious.MyCustomRefresh
or even things like some option to force the previous form to generate and setup a invoice number:
frmPrevous.SetInvoice
or
frmPrevious.SetProjectStatusOn
So not only can you shuffle values and data back and forth, but you can easily execute features and functions that you build in code for the prevous form.
In fact as a coding standard, MOST of my forms have a public function called MyRefresh.
Note that the beauty of this approach is that you can thus read + use + set values from that previous form. This allows your code to not only receive values, but also set values in that previous form. So this approach is bi-directional. You can shuffle data and values back and forth between the forms. The other advantage here is you NOT restricted to just variables, but can use fields, control values (events, properties) etc.
This approach means that much of the previous form is now at your fingertips.
So don’t try to pass a whole whack of variables. Pass a reference to the form and you have a nice ready made object at your fingertips and it makes this type of coding problem a breeze.
The usual way would be to reference the textboxes in the initial form from the popup form, like this:
Forms!frmInitialForm!tripID
Forms!frmInitialForm!OrgID
However, this tightly binds the popup form to the initial form, so that it cannot be used anywhere else in the application.
A better approach is to use OpenArgs:
DoCmd.OpenForm "frmPopup", OpenArgs:=Me.tripID & ", " & me.OrgID
This places your two values into a string, which is passed to the popup form. You can then parse the two values out of the OpenArgs using the Split function.
For more info about passing parameters using OpenArgs, see:
http://www.fmsinc.com/free/NewTips/Access/accesstip13.asp
This one could help
MS Access: passing parameters from one access form to another