How to reference a chart object on an MS Access subform? - ms-access

I have created a dozen different charts using the chart form wizard in Access (so each chart is really a separate form). I have also set up a GUI that has the following nested form structure:
frmMain -> frmSubMain -> Child0 (a subform of frmSubMain)
I have a list box on frmSubMain that lists all the charts, and when a user selects one, I use VBA to change the Source Object of Child0 to the appropriate form for the selected chart. (So in essence, a user can select the desired chart and it is presented.)
I am now trying to add a button to frmSubMain that will copy the currently selected chart to PowerPoint, but I am having trouble with the copy command and referencing the chart object. The chart object on each of the forms is called OLEUnbound0, and here is what I've tried (I have the form name for the chart as a variable 'my_form'):
Forms(my_form).OLEUnbound0.acOLECopy
Me.Child0.OLEUnbound0.acOLECopy
Me.Controls(my_form).OLEUnbound0.acOLECopy
Each gives a different error (for example, the second one gives the error "Method or data member not found"). Part of my confusion is that I have the form name but as a variable, and I'm not sure how to use that variable (since I can't use the standard Forms![frmMain]![frmSubMain]! etc.). What is the syntax for using a variable to reference a subform?

Try:
Me.Child0.Form.OLEUnbound0.Action = acOLECopy

Related

Labview - How to select data from MS access table as input array?

I'm trying to make an array from a set of selectable cells in MS access.
Here's a section of my access DB:
I want the user to be able to select the cells with these numbers, dynamically (while code is running) and an array is created by selecting different cells. How can this be done in labview?
Thanks,
Use the correct code to work with the database (NI's DB toolkit, LabSQL, call the ADO.NET code directly, etc.) and get the data you want from the DB.
Place a listbox or multicolumn listbox on the front panel, change its selection mode to have 0 or more elements, so its data type becomes an array.
Use the Item Names property for the listbox to feed the data from the DB into the listbox.
The user will now need to select multiple items. This can be done by holding Ctrl, or you can call a Windows API function to press and release Ctrl on mouse enter/leave events, or you can use the Mouse Down event to figure out which row the user clicked on and use that to modify the value of the listbox (which is an array of the indices of the selected rows).
Once the user is done, you can read the value of the listbox (from its terminal) to get the indices, and use that to index the data from the Item Names property or from the original data you got from the DB.

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.

How does one view the SQL query that a button fires in Access?

There is an existing Access program that I need to learn more about. There is a button in the program that, when pressed, outputs an Excel file. It queries some tables within it for the data.
How would I view the raw SQL code that this button utilizes to generate this Excel file? From the button's properties, I can see that its On Click event is "[Embedded Macro]". Also, it's object type is "Query".
Thank you in advance.
In the On Click row (under the Event tab in Properties), when I click on the ellipse next to "[Embedded Macro]", I am presented with an expandable section containing these rows:
Object Type - Query
Object Name - Inv File Query
Output Format - Excel Workbook (*.xlsx)
Output File - (blank)
Auto Start - No
Template File - (blank)
Encoding - (blank)
Output Quality - Print
I don't see any logic (SQL, VBA, etc.) listed anywhere, however, as to how Access will construct this Excel file that it exports. How would I view this logic? I figure this logic has to be stored somewhere because the button does actually return an Excel file populated with data.
You have the name of the query used here.
The SQL thus used is in a query called Inv File Query.
So you need to display the query objects in the nav pane (assuming 2007 onwards).
So choose this:
And then all of the queries used in the application will display. If the query Inv File Query does not show, it may be hidden. (to be fair, I would choose All Access objects - but for this we choose query). And hit F11 if the nav pane does not show.
If for some reason you STILL do not see the query, then you want to display hidden objects.
To display all hidden objects then right click on the top part of the nav pane (on the query) like this:
Then:
Turn all of the options, and now you should be able to see/view the SQL used for the query called Inv File Query
Open the form in Design view
Open the Properties sheet by right-clicking on the button and choosing "Properties".
In the On Click event, where you see "[Embedded Macro]", click on the ellipse on the far right
As a pointer, once you've figured out what's going on, I'd do my best to convert it all to VBA code. This will eliminate confusion in the future, and macros are really the poor man's way out of writing code anyway. I never, ever use macros in my Access apps.

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 = ...