How can you update many rows in database with only 1 single data in vb 2010? - insert-update

is it possible with me.tableadaptermanager.updateAll(me.dataset)?
i have 1 textbox.. i want that its value will be update multiple rows in the same table..
for example.. i'll filter the tbTransaction table with EmpName, datebegin, dateend..
so now the table is filtered with EmpName, datebegin, and dateend..
for example, for the filtered data, they all have status field.. they are not the same because they have different dates.. so i want my value in textbox.. only single value from my vb 2010 textbox to update the status field with the same data one i clicked submit button..
is that possible?

Related

Return subform values based on muliple criteria in Access

I need to select one or more values from the same field in subform 1 and display the applicable values in subform 2.
I have done this kind of thing by selecting criteria from multiple fields but not with multiple line-item values from the same field. My first thought was to build a dynamic SQL string to populate subform 2 but just wondering if there is an easier way to do this.
At the moment if I select a line-item in subform 1 (flight itinerary), subform 2 will only show the applicable flight segments for that itinerary. If a customer has more that one flight itinerary for the same trip in subform 1 I need to show all flight segments for the entire trip in subform 2.
Thanks to Lee Mac's suggestion to utilize the IN() function/operator, I was able to feed the IN() function with a subquery string to return the data I need without having to loop through a recordset. Just had to ensure that the subquery only returned values for a single field (in this case the ID field) or it would error out.
I created a function to fill in the Segment numbers in order.

Select correct row in Access Dropdown in vba

I have a drop down box in a Microsoft Access form. The columns appear in this order:
Field0, Field1, Field2, CompanyName, CompanyID
I am attempting to extract the value of the CompanyID column depending on the selection in the drop down. It happens that there are multiple rows containing the same company name. No matter which row I select containing a given CompanyName, the following code always extracts the value of the CompanyID column in the first of the rows, not the selected one. I need to modify the code to select the proper row, and don't know the row until selected by the user.
MyDropDown.Column(4)

Changing Row Source of a Lookup depending on another field

I'm trying to define the row source of a lookup field by selecting the table name from a separate lookup box.
The catalog of products comprises of about 41 Product Groups, which are then further divided into Types, some of which have over 100 types.
I have a table of Product Groups (41 groups), and I then have a separate table of Types for each Product Group (41 tables). All Type table names are exactly as they appear on the Product Group table. I want to be able to select the Product Group from a Lookup Box, and then select the Type from the corresponding table in a separate lookup box.
The images below should help give an idea of what I'm looking to do.
Set up of my first lookup box:
Set up of my second lookup:
Is this possible, and if so can anyone lend a hand ?
Thanks.
Just to summarize, you will need a single table with your TypeID, GroupID, and any other "Type" related fields.
Your Group ComboBox should have the ID field as its first column (makes the filtering much easier), So your control source should be:
SELECT [ProductGroup]![GroupID], [ProductGroup]![ProductGroup]
FROM [ProductGroup]
ORDER BY [ProductGroup];
Then in the properties for Group ComboBox on the Format tab make your column width 0";x" to hide the ID field.
The control source for the Type ComboBox should be:
SELECT [NewTypeTable]![TypeID], [NewTypeTable]![TypeName]
FROM [NewTypeTable]
WHERE [NewTypeTable]![GroupID] Like [Forms]![frmWithComboBoxName]![CboPGroup]
ORDER BY [NewTypeTable]![TypeName];
And again, if you want to hide the ID field, make the first column width 0".
You should also requery the second combobox in the afterUpdate() event of CboPGroup which will filter the second combobox based on the new selection in CboPGroup. The code (VBA) for that would be:
Forms!frmWithComboBoxName!CboType.Requery

VB 2010 Using DISTINCT in SQL

using vb 2010 on an access database
INSERT INTO UniqueTable
SELECT DISTINCT
1,2,3,4,5
FROM DataTable
This will get only unique rows in all fields and if I only specify the one field I want to be distinct it only inserts the data in that field
How can I import all data from every field where field 5 is unique?
If I set the database field properties to not allow duplicates all import fails.
Thanks
Don't use distinct in this case, you can't specify which field need to be distinct, it works for entire columns selected. Use group by instead, like: ..GROUP BY 5 .. HAVING COUNT(*) = 1. That will return all rows having field 5 value appear only once in the table, in other word distinct.

Display MemberPath instead of Value in WPF DataGrid

I have two SQL tables
In table 1 every row have value(string) in System Code column
In table 2 every row have value(int) in Device column which is ID of related Table 1 row.
Now i want to display Table 2 in WPF DataGrid and in Device Column value of System Code from Table 1. Now it's displaying ID of Table 1 row.
How can i do this?
Just create new class for the itmes, where you can store all needed properties. In your case it will be the projection of the join.
DataGrid's DisplayMemberPath relates only to the corresponding item. If data item which stands for representation of table's row allows naviagation to the property SystemCode of the Table1 then it is ok.