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.
Related
I have a form that I use for memo generation which I just added a new subform to which handles contract info. It is a small table which only has the PurchaseID (linked to the main table) and then the contract fields shown as text boxes/combo boxes.
My Issue: Originally what was happening was when a user didn't click into the sub-form shown, no row would be created in the Contract table. If you look at the picture, when the form loads the "PurchaseID" field is populated because it's an autonum linked to the main table. However even though that field is populated, if a user doesn't physically click into the sub-form, no row gets created. I just want the blank row with the default options to be added to the table.
My attempt to fix it:
What I tried doing to fix this is on the event "On Current", I wrote 1 line of code that just sets the value of the combo box to a value. I think this sets the sub-form as a focus and it does end up creating the record. The problem is, now whenever the form loads, it initially tries to add a blank row with the ID of 0 to the Contract table, essentially making a duplicate blank row every time the form opens. I think the reason is because the "On Current" event is happening before the "PurchaseID" field is linking to the main table, resulting in a PurchaseID of "0" continuing to duplicate when the form is opened.
What I need:
Looking at the picture below. How do I make it so when a user does not click in that subform box when going through everything, a new record is added to the sub-form table with the default values selected (procurement/notrequired/etc.).
Picture of form. Sub-form that has issue is circled.
I have a form that has a parameter query for it's record source - the parameter query asks for an ID number, then the form displays that particular record.
Within the form are a number of buttons that perform various functions (change status etc...) and then requery the form.
My problem is that every requery obviously re-runs the parameter query and asks for the ID number - how can I make the requery use the current ID number and not ask for it?
The button functions are quite simple -
Me.SRStatus = 3
Me.Requery
Regards,
Garry.
Me.Requery will execute the query again, so it will ask for parameters always.
Consider using Me.Refresh instead of Me.Requery
It depends on what you need. You open your form filtered by ID, that's perfect. Then the user makes changes, and here comes the deal.
If those changes are just editing the record, then you don't need to use Me.Requery. Refreshin will update the record and show the changes without calling the query again.
But refreshing won't update if the record is deleted or if you add new records. To show new records/update deleted record/reorder records you are forced to Requery.
If that form is just for editing an existing record, then use Me.Requery so the existing data will be updated without executing the query again (and then asking for a parameter again).
You can read more about this
here
UPDATED ANSWER: OP said that Refresh works, but in event Form_Current got code that enables/disables the buttons according to a field value. So the right answer would be:
Me.Refresh
Call Form_Current
Is it possible to have the same combobox appear on multiple forms with linked selections?
I have several forms used for data entry and on the Main form (which has links to the other forms) there are two comboboxes, one queries Year and the other Branch. Based on the selections of these two combo boxes the other forms with apply filters on activate so that users can enter data for their specific branches.
What I am trying to do is have the same comboboxes appear on all the forms so that users don't have to go back to the main form to change the year or branch.
What you're saying is this:
On Form A the user would choose the year and the branch.
On form B their selection would continue to appear.
Option 1: If they can change it in form B you need to copy the value (set the default value) when you launch form B.
Option 2: if they can't change it in form B just put the value inside a (locked) text box, so they will see what the year was but they wouldn't be able to change it.
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
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.