How to get event when moving recordsets Access form? - sql

I have an Access form which uses SQL to populate dropdowns. This SQL is using a value in the form for a combo box cb_Priority, such as:
SELECT ProjectPriorities.ProjectPriority FROM ProjectPriorities WHERE (((ProjectPriorities.[mType])=[Forms]![testQuery]![mType].value));
In other words, I am using the current recordset to populate a dropdown on the form.
I would like to call the following when a user moves between records (ie which one is currently displayed in the form).
Form_testQuery.cb_Priority.Requery
This repopulates the form dropdown correctly.
However, I cannot find the event for what I would imagine to be something like
Form_RecordsetChange()
Form_RecordsMove()
How I trigger this .Requery method to allow it to run each time the userform updates to a different record?

The event you are looking for is: Form_Current.

Related

How To Fill Textbox With Datase Using Filter Button

Program ScreenShot
Hi I am creating a program and would like to ask for help.
I would like to fill the data on the four textboxes shown when I press the "ADD" Button (the input would be coming from the dataset), but first, the user must input a value on the other textbox at the top (the Item Code to be exact), basically to filter it first.
Would like to know the code on/or how to do it. TIA
Add a search button. Once clicked, execute a query for the Item Code in DB to fetch the related record.
If record exist, Show Update button. Show the data in the textboxes. For this bind the textboxes with the datasource (i.e. DBSet used to fetch record from DB).
If record does not exist, Show Add button. Once data is entered into the textboxes, construct an insert query with the textboxes data and execute the insert query in DB.
Show the update or insert success/failure message to user.

Prevent all Access Form ListBoxes from updating

I have a form that gets populated with rows of data from a database. I want to add a listbox to each row for the user to select a letter grade. When I run the form all the data looks correct, but if I update a single listbox all the listboxes in the form update to the same value. It seems like the listboxes aren't independent of each other.
An unbound control will always display the same on all records.
For individual display, you must bind it to a field of the record - or redesign your form in some way.

Access 2007 need to Force a query update based on a field change in a form?

I have an access database with several calculated fields in text boxes on a form. Most of those update immediately after the data included in the calculation is updated. However I have a couple of those calculated field text boxes that include a data point from a Query, when I update a filed that would impact the query results, those calculated fields do not update correctly until I click through a few records or close and open the form.
How can I force that specific query to update after updating a specific filed on the form?
Try refreshing the form.
Me.Refresh
As an aside, you really should get out of the habit of using bound forms, because you have to end up kludging a bunch of stuff (like this) to get it to work properly, and the Undo functionality (cancelling the entry of a new record) is unstable at best. By unbinding a form, you can have more control over how it reacts to calculated fields and dumping a new data entry is a snap.

microsoft access requery updates form after 2 requeries

So I have a form (A) , a form (B) , and a table (X). Both forms are based from queries of table (X). The user may click on form A and it will open form B filtered to what that user clicked on. The vba for this works, and is:
docmd.openform "formB" , , , "mykey = " & me.mykey
Once the user is on form B, they have the ability to update table (X) using a combobox dropdown. The user on form B may select a record and a dropdown next to the record that changes information on table X. Once the information is changed, it is updated in the backend table accordingly.
My problem is that these changes are not reflected in either form. The vba I tried to use to update the forms is
forms!formB.requery
forms!formA.requery
The strange thing is that if I click on form A and reopen form B to change a 2nd record, I can now see the previous update. So the 2nd requery updates properly for the first change. Any ideas?
It is a bug in access, not my code. If a combo box has focus when the requery is ran it will not update forms properly, although the table in the back end will still update. I fixed it by added code to the combo box that changes focus after update, now it works.

Trying to open another form in Access based on a field in the current form

I have a form that's just a list of descriptions (desc.) of other forms. Right now, when you click on a desc., the appropriate form opens; but it's done through a series of if statements in a macro. This isn't going to scale well once more forms are created.
I have a table that has the desc. and the form that is supposed to go to. I want to write a script that uses this table to open the new form based on the desc. clicked, but not using if statements. The end goal is to be able to just add a row to the table for any future forms that are created without making changes to the script or form. Is there a way to do this?
Use a combo box whose row source is a query which selects the form description and name fields from your table.
The combo will have 2 columns. You can set the width of the form name column to zero if you want to present only the form descriptions. If you make the form name column the combo's bound column, you can reference it conveniently in a DoCmd.OpenForm statement. For example, you could have a command button whose click event opens the form which is currently selected in the combo ...
DoCmd.OpenForm Me.YourComboName.Value