I Have a Query that each field represents a date, so I was wondering If two combo box with a button could show a default view like resource, gender, ETC, And all the fields between the two combo box like Apr_1 to Apr_15
NOTE I'm using Access 2010
After couple of weeks finally solved it using dynamic SQL statement if anyone is interest in this method please let me know
Related
I am trying to "convert" a more complex Access database/user interface into a custom app using VB .NET. I am also a NOOB in .NET so please be gentle.
Here are the steps I'm trying to take to duplicate my results in .NET
1) Create a Data Source (dsServer) to my SQL Server that pulls all tables and all data. I created this Data Source in my project already using the UI.
2) Create a Data Table (dtResults) in my Data Source that pulls all the info I need from 3 tables:
[Person] - This is a single entry list.
[Primary Teacher] - This is linked through column (Primary) on the [Person] table. This will return single results.
[Test] - This is liked by [Person].ID. This table has multiple entries per [Person]
I have also created this data table in my project under the data source using the UI.
3) Populate 12 comboboxes on a form that will be used to "filter" my results onto a DataGridView. Each combobox needs to be a DISTINCT list of what is in dtResults. Each time a combobox changes, the results in the DataGridView need to be updated as well as all the other comboboxes. (narrowing the choices to only what is available)
4) Create a DataGridView on the same form that will display the filtered results.
I don't seem to have any issues with creating the datasource or the datatable. What I can't figure out is how to populate the comboboxes from the datatable or how to bring back my filtered results to the datagridview.
Any help on the best way to accomplish this would be great.
It sounds like you want a single results gridview to be filtered by the optional selection of 8 different combo boxes.
When you generate the query for the gridview, you'll need to selectively include the where clauses for each combo box with a value. That should be as simple as sql += " AND Combobox2Column = #Combobox2Value " for each combo box. Don't bother using the column like '%' pattern for combo boxes with no selection. That can have negative performance impacts and is not necessary if you build your query in VB before sending to the database.
(This is a scenario when using "WHERE 1=1" as the first predicate in the where clause comes in handy. It does have a little bit of overhead, but it standardizes all the rest of the predicates to always start with AND to prevent the additional overhead of determining if the specific combo box is the only combo box with a value selected. If your query requires any other filters not based on the combo box, this becomes unnecessary)
Another important factor is that changing any combo box will trigger the event to refresh the contents of the grid view. Put your combo box refresh logic in a dedicated method, separate from an event handler. Then you can easily call that method from the event handler for each combo box (or any other control/event).
Hope that helps.
I have a form in MS Access (datasheet view) which is based on the output of a SQL Server query. Now this is used in a front end where the user needs to be able to select from a drop down the value for one of the columns, 'NAME'. I tried adding a combo box which is mapped to take distinct names from the SQL Server table to the datasheet form but the results were not as desired.
Kindly provide advice on how this can be possible. I did this before by using a lookup on a similar MS Access database, but in a multi-user environment, the database was corrupted and now I moved my back end to SQL Server.
Just got the answer to my question. here are the steps I followed.
a) Add a combo box to the datasheet form in design view like Johnny Bones suggested.
b) Create a drop down with values.
c) Point the Control Source property to the field in the SQL Server table which needs to be updated, in this case NAME.
d) And voila, your drop-down now shows the values in the table and you can include a drop down for the user.
Thank you for pointing me in the right direction Johnny.
In datasheet view, I think you'll need to set up the field in the table.
Open the table in Design View
Click on the specific field in question
At the bottom you will see 2 tabs; General and Lookup (I
apologize, my work doesn't allow me to upload pics, so I hope you
can visualize it)
On the Lookup tab, change the Display Control from Text Box to
Combo Box
At that point, the properties should look familiar if you've worked with Combo Boxes, and you can change them to suit your needs.
I have a form with two unbounded comboboxes that work fine (one lists several age values and the other lists several region). I have a subform, which is a query that refers to the comboboxes, but I can't get it to update when I change values in the comboboxes.
My query is:
Select * from mastertable where (age=[form]![masterform]![age] and region=[form]![masterform]![region]
The query works in the sense that if I run it and input the parameters manually it works. It also works in the sense that if I create a button that runs the query on the form, it produces the correct table/query.
My question is how do I get the query to work as a subform? I'd like to be able to select values in the combo box and see the subform update, rather than having to click on a button that runs the query separately from the form.
I also tried creating a table that the parameters on the form can bound to, then relating those variables to the mastertable, but that also didn't work.
How do I get a table/query subform to update as information about the parameters changes in the form? I'm guessing it will require some VBA code on the "after update" event associated with the comboboxes. Any idea how to do this?
Thanks
I figured it out. I just put a little VBA code that requeries the subtable after update.
Code is [subform].requery
I hope to create an entry form that provides multiple entry fields like it appears in microsoft excel where the column headers are up there and several rows below for data input.
i know textboxes have to be placed one at a time and only accept one input per text box and that would take awfully long to just create a form with probably just 10 rows and 10 columns.
how do i go about this.?is there any tool from the toolbox that can help design this form? Id also like to pass entries from the form into the database all in one shot so id appreciate it if the control supports that too...
this is a picture of what id like the form to look like...
Please help out.
Maybe a DataGridView would be appropriate?
I have a SQL database where one of my fields 'Status' has one of 10 entries in it (not from a dropdown list). I let some people have access to the data through an Access database, they can add and modify entries.
My question is, in Access, how can I make it so that the 'Status' field is a drop-down list from which the users can choose from (the 10 entries which are already in the SQL database)? It would be easier for them and also mean that mistakes cannot be made.
Many thanks
Scott
The usual way to do this is to use a combo box on a form with the row source taken from the look-up table and the bound column set to the field (column) of the table to be updated.
In Access you can add lookup information to a column. That will automatically display a dropdown list.
Step 1: Start the lookup wizard:
Step 2: After the wizard, the lookup settings should look like this:
Step 3: When your users open a table, they should see the dropdown box:
In addition to the solution described by Andomar you must not use another table as the source for your lookup. You can also provide the lookup-values in a list, which is hardcoded in the table-definition. This is fine for simple scenarios where the lookup is something that is not likely to be changed.
Several issues here:
table datasheets are not suitable user interface for users.
you can create a saved QueryDef and if you view the properties of a field, the second tab is just like the second tab in table design, and allows you to use a combo box as your display type in your query. I would generally recommend against this, as, like table datasheets, a QueryDef is not a proper UI element, and if you use the saved query in other queries, you can run into the same problems that cause lookups in table fields to be such as bad idea.
you're building a UI, so use the tools that Access provides you for building a UI. That means a form. Your form's recordsource would have the bare data, and you'd create a combo box on your form that is bound to the field in the table behind your form, and displays the values from the lookup tables. There's a wizard to step you through this. If you like the look of datasheets so much (column sizing, sorting, show/hiding are all features that are nice in datasheets), you can set your form to display as a datasheet.
My advice is that for building a user interface, use the tools Access provides for creating user interface. In my opinion, a dropdown list belongs in a form, and nowhere else. While I occasionally might add one to a query for quick-and-dirty editing, I would never do that in objects that users are going to use.