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

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.

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.

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.

Flex/AS3: removing item from ListCollectionView

I used a temporary array to populate a ListCollectionView. Later, I have a screen that displays a DataGrid using the ListCollectionView as a dataProvider. The user can delete a row in the DataGrid by selecting the row then clicking a Delete button.
How can I access the original source that ListCollectionView uses, and delete the item from there?
After I do that, will the item also be deleted from the ListCollectionView automagically, and no longer be shown in the DataGrid (or does something need to be refreshed)?
UPDATE 1
Does the following sound like I'm on the right track? (I want to remove it from the source (is that the ".list"?) of the ListCollectionView, not just from ListCollectionView.)
[Bindable] private var _myLCV:ListCollectionView=new ListCollectionView(new ArrayList());
...
var obj:Object = _myLCV.getItemAt(myGrid.grid.selectedIndex); // get item user selected
_myLCV.list.removeItemAt( _myLCV.list.getItemIndex(obj) ); // delete item from source
UPDATE 2
I'm not sure why (I'm using SDK 4.5.1A), but I seem to need to add the following line of code to the above code in UPDATE 1, for the DataGrid to reliably update and show the deleted row:
_myLCV.refresh();
My impulse is to recommend deleting the item from the ListCollectionView using removeItemAt.
If you truly want to access the source instead of dealing with the collection, then it depends what type of ListCollectionView you're using.
If you're using an ArrayCollection you can access the source using the source property.
IF you're using an XMLListCollection, you can access the source using the source property.
There isn't an inherent source property in the ListCollectionView, but the List property may suffice.
In any case, removing an item from the ListCollectionView or the ListCollectionView's source should automatically update the DataGrid. IF not, you can call the refresh() method on the collection.
Spark DataGrid, like other list base controls such as List or even DataGroup, would observe change events from its dataProvider. The change events may include item removal, update, sort and insertion. This provides the convenience of updating the control by just updating its underlying data.
That said, if your intent is to "refresh" the datagrid to stay up to date with the LIstCollectionView, by modifying the array and then refresh would rather be unnecessary.

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

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

In VBA/Access get value from current record when changing records

I have an Access database. I have a map control embedded in a form (using MapInfo, but that's not important). When a user goes from one record to another I would like the map to re-centre on the appropriate coordinates. To do this I need to get the coordinates which are stored in the current row of the table which is the data source for the form. My question is how I access this value. This is pretty simple, right?
I have worked out that the "On Current" event is triggered when the record is changed but I can't seem to refer to the xcoord and ycoord fields in the current row.
This page seems to suggest that I need to create a module to do this. Surely there's a simpler way?
Thanks in advance!
Update: If I put a pair of textbox controls in the form that display the x and y coordinates then I can access them by doing Me.x_coord. Is this the answer?
In Access VBA you can reference the fields of a bound form's recordsource with the syntax:
Forms!your_form_name!your_field_name
In your case, you can grab the current x_coord with Me!x_coord. No need to bind it to a control to get the data.