Double Clicking Queries In a List Box to display The Exact Query - ms-access-2010

I have a Listbox with a List of my queries, I need to be able to double-click one item on the List, and it displays its Query. How can I go about it?

Like this:
Private Sub QueryList_DblClick(Cancel As Integer)
DoCmd.OpenQuery Me!QueryList.Value
End Sub

Related

How to clear listbox items?

I have two listboxes, Listbox1 and Listbox2. When I select few values from Listbox1 to Listbox2 and hit save the first item on the listbox2 gets recorded into the database but I can see still see all the all the items on Listbox2 when I hit edit from saved list in webpage. Now when I want to clear listbox2 in edit mode i.e. move all the selected items in Listbox2 to list box 1 and hit save, database gets cleared, no values are saved but my Listbox2 donot clear those items. Any suggestions?
You can use Linq to set all the ListItems selections to false.
ListBox1.Items.Cast<ListItem>().ToList().ForEach(x => x.Selected = false);

How to switch views from a multiview upon a click of a treeview item?

I'm trying to create a prototype in asp.net web form where clicking on a treeview item changes views within a multiview. I've created all the views that I need and I now need to configure it so that clicking on a treeview item will change the multiview to the corresponding view.
My treeview has this structure: A project has 2 subcomponents: parts, users. Furthermore, parts can have multiple subparts. So when clicking on a project, I want to load the view associated with projects, in this case, its called view1. And when clicking on a part, it should load view2, and so on.
My best guess is that I can somehow extract the level(counting from root) of the selected treeview item and from there load its view. But how would I do that? Also, since project has 2 subcomponents which each have its own view, a treeview item level might not be sufficient since both parts and users will be on the same level. So how would I go about solving this?
I've figured it out.
TreeView.SelectedNode.Depth provides the level at which the selected node is at. I thought I had to do some recursive traversal from the selected node and stuff like that but looks like its a lot simpler than that. =)
I still have the problem of having multiple views that correspond to the same depth though.
Here's how I did it.
On my page I have 2 columns. On the left is the treeView1 and on the right Multiview1 with several Views.
Page Load is set at MultiView1.ActiveViewIndex = 0
By double clicking the TreeView in Design Mode, it creates the Sub routine Handler
Protected Sub TreeView1_SelectedNodeChanged(sender etc etc etc)
End Sub
I added the following code inside the Subroutine
If TreeView1.SelectedNode.Value = "value of the treeview node" Then
MultiView1.ActiveViewIndex = 1
End If

How to delete empty element in popup list

I have a question about a suspicious behaviour in Forms Builder 10.1.2.0.2.
When I have a list object (pop up list) I can define some values in the attribute palette of the object.
So you can set a shown name and a value behind. In this little window to set the items of the popup list you get automatically a white empty item at the end of the list. When I click now on this empty item (you do so, when you want to add an item) Forms Builder automatically adds an new empty item at the end.
When I click this new empty item, Forms Builder adss another empty one ... and so on.
It´s very suspicious because, when I end this dialog with "OK", it will be saved and when I open the form (over web) I have at the end of the list one, two (or more) empty elements in list.
But I can´t delete this empty ones from the list in Forms Builder.
So my question:
how can I delete empty items in a popup list??
I try it with hit "del" button at keyboard or delete the set value for the item (I hope Forms Builder delete items without value). But all does not help.
ctrl+shift+<
or
On my german keyboard it is:
ctrl+< for deleting a line
ctrl+> (= ctrl+shift+<) for adding a new line
When adding the list elements and list values, make sure you only add the ones you need, if you need 3 elements in your list don't click on the 4th box in the property palette, this will add one more list element.
If you have a blank element and you want to remove it, the only way is to click on the property without clicking the "More..." button press on the "Inherit" button on the top of the property palette, this will reset the list elements and list values so you can add only the elements you want.
if you still have extra empty option then make sure of these:
1- make pop list item required
2- if its database item ... make sure you have yes on databse item and column name filled
3- make the column in table to have default value like '1'
hey perhaps you should try this ctrl+shift+,

How to reload the page in asp?

I have 2 dropdown list boxes in my asp page where I need to select category and sub-category.
Sub-category dropdown list will be populated based on the category dropdown list box selection.
The problem is the sub-category list box is not loading accordingly when i select an item in category list box.
So I am going to previous page and click on the button to get the current page(where cateory & sub category list boxes are located) and selecting the sub category details(now sub category list box got loaded).
Is there any way to stay on the current page and get the sub category list box loaded for selection at first time itself.
Please any one help..
Set AutoPostBack=true and handle ChangeItem event at category dropDown.
#Kanchana: This should help get you started -- http://www.satya-weblog.com/2009/08/jquery-ajax-example-of-select-values.html

Editing row of a datagrid in ASP.Net VB.Net

I'm working on a piece of code at the moment that uses an older style DataGrid to allow the user to enter information into the table. It already has an add and delete button. Currently the user enters information into 3 textboxes that are in the footer, and the other rows use labels to display the information.
Essentially what I am wanting to do is take the line that the user has clicked the edit button on, and move the text from there in to the footer (deleteing the row that it was displayed on) so the user can make changes and then click the add button again. At the moment I have tried using FindControls to find the textbox and setting the text that way but it doesnt like it. Any ideas?
A few things need to be clarified - are you referring to the older .NET "DataGrid" control or the newer "GridView" control. Also, is this a web or winforms app?
My suggestions -
Have you tried to programmatically add and set the TextBox controls by handling the GridView1_RowEditing event?
To remove the row that's been edited - remove it from the datasource and rebind the grid.
list.Remove(itemToRemove);
GridView1.DataSource = list;
GridView1.DataBind();
Then, take the data from itemToRemove and use it to programmatically create and set textboxes in the footer.
If the third column of your data grid is called "Name" and contains the name data, you would create and set the third column's footer row TextBox value like this -
GridView1.FooterRow.Cells[2].Controls.Add(new TextBox { ID = "tbName", Text = item.Name });
How are you using FindControl? It always helps to post your code ;)
You should be able to execute a FindControl() on the footer row and get the textboxes with no problem.
GridViewRow row = GridView1.FooterRow;
TextBox txt1 = ((TextBox)row.FindControl,"TextBox1"));
Essentially I changed what I had originally planned. Instead of moving the text from the row to the footer textboxes and deleting the row I instead used the EditCommandColumn to create a link button like so
<asp:EditCommandColumn ButtonType="LinkButton" ItemStyle-ForeColor="Blue" EditText='[edit]' UpdateText='[update]' CancelText='[cancel]'></asp:EditCommandColumn>
I also had to add EditItemTemplate to each column, with a textbox in each, and bind the data to the textboxes in the same way that it was bound to the labels in the ItemTemplates.
Then using the ItemCommand event handler I added some code behind to set the EditItemIndex to the row that was being edited.
Private Sub GoodsList_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgdGoods.ItemCommand
Select Case e.CommandName
Case "Edit"
dgdGoods.EditItemIndex = e.Item.ItemIndex
Case "Cancel"
dgdGoods.EditItemIndex = -1
Case "Update"
dgdGoods.EditItemIndex = -1
'Update details here
Then, at the end of this rebind the data to the datagrid. With the EditCommandColumn it will automatically change from displaying the Edit button to showing the Update and Cancel buttons on the line that is being edited.

Resources