How to stop ComboBox on subform from refreshing (requering) in MS Access 2010 and later - combobox

On the main form there's a linked subform with combobox on it. The underlying query of the combobox is rather complex and takes a few seconds to complete. In Access 2007 it is run only once when the form is opened. In Access 2010 every time I change the current record on the main form the combobox is refreshed and thus it takes awhile to move to the next record. Is there a setting in Access 2010 and later to change this behavior?

Related

Automatic disabled MS Access From textbox

I have a user form in an MS Access Application that I developed 20 years ago that I'm trying to revamp. The problem is that I cannot figure out how some controls on a subform are being disabled. I have looked through every line of code on the form and the subform and cannot figure it out.
The selected text indicated a category of item and if the item ends in man-hours values, it enables the 6 controls on the left (3 textboxes and 3 labels), if it ends in something other than man-hours it enables the controls on the right. This all works correctly, but there is no code that I can find that is changing these values. Is there a way to trace all event procedures that are being triggered by this combobox change? (It is not any of the combobox event procedures listed in the code).
I have searched the entire project for the word enabled, locked, and "for each" in case I had disabled it in another obscure manner, but this does not appear to be the case. I'm really stumped.
Thanks,
Boris
Ok, so it looks like I'm a dummy, the controls are disabled through conditional formatting, which I never thought to look at.

Creating a gridview to select records in ms access vba 2007

I am working on MS ACCESS 2007.The application I am working on has a dropdown box on one of its pages.The number of values in the dropdown box is so high that it goes beyond the screen size and it becomes difficult to see some values.This dropdown is to be converted into a grid now and the values should be made selectable.
Can anyone guide me how can I go about this?It's a complete new application to me.The data source is sql server 2005.
The ListRows property of Combo-Boxes defaults to 16. Setting this value to a size less than the Form height is a better solution (IMO) than using a grid (datasheet in Access) since you will lose the Combo-Box's Auto-Complete functionality, which is of great benefit users who must select from very long lists.

Update data in ComboBox while form is still open

I have form in which I can change the name of stations in my database (SQL Server: in table Stations).
To choose which station I want to edit I've used a combobox.
What I want to happen now is that when I update a station, my ComboBox with stations immediatly gets updated with the edited station.
Is there a way to do this or is this impossible?
I am assuming that this is a Windows Forms application based on the subject. If this is the case, then you have most likely performed databinding, perhaps using a DataTable or a collection, to the ComboBox.
If this is the case, and the object that you have databound supports System.ComponentModel.IBindingList, then all you need to do is add or update the record in the underlying object.
When this happens, the object that has implemented IBindingList sends a message out to any controls that are "listening" and tells them what just happened. The control will then update their data/user interface to reflect these changes.

MS Access Datasheet View vs .NET DataGridView - Newbie Questions

I'm trying to migrate (mostly mentally at this point) from MS Access to .NET for database programming. I've found one of the first tests to be fairly painful. I'm trying to recreate MS Access's datasheet view in Visual Studio.
Features I use in MS Access Datasheet View that I haven't immediately found in the DataGridView. I'm wondering if anyone can help me out here. I'm assuming that a DataGridView will be used to edit records as opposed to being used as a search/list only.
1) Form Level BeforeUpdate Event - Here I typically run validation code
2) Textbox level BeforeUpdate Event - If I'm feeling anal I'll run validation code here.
3) In MS Access you can sort by multiple columns at once
4) In MS Access columns positioning, sort order, width, row height, etc. are properties
that can be saved in your user's settings (text file or table) and reloaded next time they open the form.
5) In MS Access you can refer to one of the form's recordset fields like this: Me!dteDateTimeEntered = Now() This allows you to edit/enter certain types of data without having to show it to the user.
6) Moving from one row to another automatically saves the changes you made to the record you just exited (assuming you made some changes). It's unclear to me if .NET DataGridView works this same way or if this is something that is determined by the code you use.
7) I often program so that the user can double click in a cell and get a certain action such as dialing a phone number, opening Outlook with an email address inserted, bringing up a windows folder or a picture viewer, or opening a single-record details form. In order to do this I usually grab the primary key of the current record using code like: Me!ContactID or the data from the cell they double clicked in. How can I get this data for the current record in a DataGridView?
8) In MS Access DataSheet view you create textboxes and bind them to specific fields, then you usually name them like txtFirstName. This way you can refer to the value of the textbox using Me.txtFirstName.Value or Me.txtFirstName.Text or you might also choose to refer to the value of the recordset field using Me!FirstName. It appears that .NET's paradigm is totally different so I'm confused. May I create bound textboxes in a DataGridView?
Have you spent some time looking at the documentation for the DataGridView? A quick glance at it seems to answer most of your questions more or less prima facie.
You will have much finer control over many of the items in your wishlist in .net than with VBA. You may also find that the native .net controls are a bit clunky, and prefer to use someone's enhanced control. For data lists in Winforms, for example, I've found Philip Piper's ObjectListView very elegant, extensible and time-saving for handling pretty much everything in your wishlist.

How do you get a Microsoft Access form to refresh a computed column?

I have a Microsoft Access form that is bound to a linked SQL Server table that has a computed column. I have a control bound to the computed column.
I already realize that the computed field cannot be refreshed until AFTER a record is saved. Beyond that, what is the best way to refresh that textbox that is bound to the computed column after save.
I would prefer not to do a me.requery (a requery of the whole recordset).
Is there a way to JUST refresh that one field?
EDITED FOR CLARITY: There are actually a few strategies to consider.
Form.Refresh() will refresh your Form's recordsource capturing modifications and deletions to existing records and will stay positioned on the current record. However, you would not see any NEW records that were added since you opened your form.
Form.Requery() will re-run the Form's recordsource query. You will see all the Form.Refresh() changes AND it will show you any new records. On the UI, Form.Requery() repositions to the first record.
Form.Control.Requery() is similar to Form.Refresh() in that you will not change record position or see NEW records. It will update your control, assuming the control is based on a query/table.
You'll need to be sure that the triggering event involves a database update. There can be cases where the control's AfterUpdate() precedes database I/O, which wouldn't help you.
Thanks guys. Here it what worked.
In the Form AfterUpdate event I did a Me.ControlName.Requery. This was perfect as it did not do a complete form refresh or requery.
I just experimented with different event/method combinations until I got the best result.
Thanks for the input.
Seth
2016 (related) Answer: In Access 2016, I have a control that is a calculated field based on values in 4 other bound textboxes. I set the Control Source for the calculated field to be =gsngCalculatePaymentAmount([txtInterestRate],[txtLengthOfLoanInYears],[txtSalePrice],[txtMoneyDown]).
But I needed the value to be refreshed whenever ANY of the values for any of those 4 textboxes changed. Had difficulty in making the calculated value refresh. SOLUTION: In the AfterUpdate event in EACH of the 4 textboxes whose value was being used for the calculated field, I simply did the following:
Dim v1 As Variant
v1 = Me.txtMyCalculatedTextbox
Simply referencing the value of the calculated field resolved it!
Rex
Have you tried .Refresh for either the underlying recordset, or for the bound control? I would expect it to work for a Jet/ACE back end, but the interaction with different database server back ends is going to be non-predictable.
There might also be an interaction with you ODBC refresh interval, but I would expect a manual refresh in code to take care of that.
Where to call it is another issue -- I would assume the appropriate place would be in the AfterUpdate events of the controls bound to the fields the calculation is based on. But you might have to save the record for the server-side calculation to happen -- Refresh alone might or might not do the trick. I know with Jet/ACE data sources a Refresh saves the record, but I don't know for certain if it behaves the same way with ODBC data sources.
I did it this way (the control source of txtTextBox is an SQL Server field whose value is computed):
On Error Goto ErrorHandler
'After saving data when I wanted to see the updated value of computed field
txtTextBox = txtTextBox & ""
ErrorHandler: If err.Number = -2147352567 Then 'The data has been changed.
Resume Next
else
msgbox err.description
end if

Resources