Forms :: Requery Control On Subform From Main Form - Refresh List?
Sep 8, 2014
I have a form called Add New Delegation, i have combo box of Institution names on the main form and a subform for Agreements discussed. with a combo box called agreements. I successfully cascaded the combo boxes so that the agreements discussed on the subform are filtered by their respective institutions on the main form. However i am unable to refresh the list each time a new institution is selected as the Macro will not allow me to requery a control on the mainform from the subform..
I have created a form "PAYMENTS" that include a sub form "PAYMENT DETAILS".
In the sub form control Policy Id is defined as combo box, and retrieving the list from Policies and Payments where Policies.Client=Payments.Client the query of Combo Box is as follows:
Code:
SELECT POLICIES.[POLICY ID] FROM POLICIES WHERE (((POLICIES.PAID)=False) AND ((POLICIES.CLIENT)=[Forms]![PAYMENTS]![ClientId]));
Only first time Combo Box display the Policy Ids according to the Client, but when I change the client and always displays the previous clients Policy Ids.
how to retrieve correct list of Policy Ids according to the Input Client in Payments.Client control
I have setup my main form with 2 subforms to mimic a split form; this works fine.
To search for a record, I am using a cbo on the main form which I would like the user to select from. Once selected, then this will populate the first subform.
This is the code I have for the cbo:
Dim intAnswer As Integer If IsNull(Me!cboCaseNoCFDWit) Then Exit Sub With Me!sfFocus.Form.RecordsetClone .FindFirst "Me!sfFocus.Form!CaseNumber = """ & Me!cboCaseNoCFDWit & """" If Not .NoMatch Then If Me.Dirty Then Me.Dirty = False
[Code] ....
I get an error at the .findfirst; states that the Microsoft Engine does not recogize Me!sfFocus.Form!CaseNumber
And the reason I am not using a regular split form is because I cannot, get the form to the size that I want. The splitform works great with the code above (a few changes to it of course), but the bottom of the splitform (datasheet) is too long and I cannot shorten it.
I have a Main form 'frmEmployeeInjury' with a subform 'frmInjuryDetails'.On the subform is a date field 'dteDateofInjury' and on the main form a command button 'SaveRecord'
What I am trying to do is hide the command button on the main form until a date is entered in the 'dteDateofInjury' field.I have looked online and found information on main form and subform referencing, but I can't follow it very well without examples.
Code:
Private Sub dteDateofInjury_AfterUpdate() Me.Forms![frmEmployeeInjury]![SaveRecord].Enabled 'Me.Parent.cmdSaveNewInjury.Visable 'Me.Parent.cmdSaveNewInjury.Enabled End Sub
I have a form with a subform which resides in a tabbed control. In that subform, I have a textbox in the footer that sums values in the detail section of the subform.
I have a textbox on my main form that should display the same data that is in my subform footer textbox, but it is giving me the #name? error.
This is the expression in my subform footer textbox (which returns the correct result):
TxtSubtotalHQPCalc - =Sum([ActualHQPCalc])
And the expression in my main form textbox (which returns #name?):
I have verified that my subform name and textbox names are all accurate. This is very frustrating because I am using this exact same method in a different database with no problems!
I have a main form that has two subforms, subform1 and subform2, both connected to the main form. When I enter data into a field in subform1 I want subform2 to requery and update to show the calculated results from the new or changed data in subform1.
I found that if I do a refresh it works when changing the data but not when entering a new line of data in subform1. I tried some code in the after update field of on subform1, but cannot seem to get anything to work.
Me.[subform2].Form.Requery
Does not work. It errors and says it cannot recognize subform2 as a field. I have tried a field name on subform2 but I still got the same error.
Essentially I have a form_A with several tab's and then one list control box in each of those tabs. At present if you double click on any item within the control boxes your taken to another form_B with info about that item and when you close that from down again if refreshes form_A.
Is it possible to only refresh the specific list control box that is active instead of refreshing the whole form ?
There are 2 levels of forms, the main parent form is called INSPECTION. Then there are two subforms: TESTRESULTS and addTESTRESULTS.
the form TESTRESULTS is linked to the TESTRESULTS query "QTESTRESULTS2". This query looks at two hidden fields on INSPECTION called FILE and REPORT NO. The query finds all fields inside of TESTRESULTS that match the two criteria. This works fine. The form TESTRESULTS is linked to the QTESTRESULTS2 query as direct data source link. This works fine.
a temporary table has been setup to append test results to TESTRESULT table. This works fine. What doesn't work fine is updating the subform TESTRESULTS when needed. I want it so that the welder enters his information, clicks save, the info gets appended to TESTRESULTS table and instantly updates on the form for them to verify.
[inside subroutine for saving a record] all efforts at accessing this form have failed. I've tried !form!subform!requery, it has failed, I've tried making dummy fields inside the form and accessing them and that has failed, I've tried .setfocus on the form and that has failed, each time the compiler tells me 'unknown field', when in fact I'm trying to hit the form itself.
Its worth mentioning that I've set events [on this form for any kind of update event including mouse click] to Me.requery for this form when you click on it, it updates, but I need to automate this somehow, and the form just seems untouchable via VBA.
I have been using AYS2000 database example from Rogers access library. I have been in the process of modifying to meet my needs. Although I have run into a problem that was prevalent in the original database example. I have attached the original database for your reference.
Problem: At the bottom of the database beside the "New Response" button there are 2 combo boxes that allow you to select the survey and response in which you want to view in the subform. Although when selecting the response the subform does not always update the record in the subform. It would appear that the problem occurs only after a response has been previously selected. I have tried adding additional code to refresh and requery the subform already without any success.
Lets say I have Form A and Subform A with the parent-child relationship established that works well. Subform A has a Text box control that is getting display when I include the subform in Form A.
Now, I decided I dont want to include subform A in the Form A. Is there a way for me to show the contents of that Text box control in Form A without attaching the subform in the main form (Form A)?
I read somewhere that to refer a control on a subform, I have to use the code - Forms!mainform!subform.form!control. But this would be in VBA. What is the equivalent of this in a Control Source in the main form?
If I have not explained myself correctly, please do let me know.
To summarize, my question is without including the subform, I want to reference the values of the subform in the mainform. (I have some design necessity for this requirement) Is there a way for this?
I have a form which contains one subform. On the subform I have a command button which saves the record just entered. On the main form I have a "refresh form data" button which updates the main form so that the calculated controls can show the correct results based on the data just entered?
Can anyone tell me how I can get the "save record" button in the subform to subsequently refresh the data in the main form as well, thus saving a button???
I'm using form with subform. Main form header contain a combobox. I need to check the combobox is null or not before update a subform filed. If combobox is null then its back to Main form combobox from subform. The code below that I'm trying to:
Code: Private Sub AssignTo_BeforeUpdate(Cancel As Integer) If IsNull(Forms!frmDepartmentReview!cboDepartment) Then MsgBox "You must select Department first", vbInformation Forms![frmDepartmentReview]![cboDepartment].SetFocus End If End Sub
Then I'm getting 2110 run time error
Access can't move the focus to the control cboDepartment.
I believe I did this before awhile ago but for some reason I keep getting an error.
I have a Mainform (frmMain) that has a Subform (frmSub). On frmSub I have 2 comboxes (strCom1 & strCom2) one is set to invisible (strCom2.Visible = No).
So using the "On Open Event" of frmMain I want make strCom2 visible if strCom1 = "Read Only". Ofcourse I will also need to place the vba on the On After Update event. Below is what I have so far but doesnt work.
I get Run-time Error 2427 "You enetered an experssion that has no value"
Code:
Private Sub Form_Open(Cancel As Integer) If Me!frmSub.Form!strCom1.Value = "Read Only" Then Me!frmSub.Form!strCom2.Visible = True Else Me!frmSub.Form!strCom2.Visible = False End If End Sub
I set up several combo boxes to display Tables from msysobjects. The record source is using a WHERE clause to display certain tables both Linked and Local. Occasionally, when clicking the dropdown arrow, the box only displays local tables. This situation seems not to matter whether tables have been newly linked or unlinked. despite having both a me.requery and a me.refresh in the code and/or even clicking the Refresh All button on the ribbon menu, the form does not seem to update the combo box to display both linked and local tables.
In further testing, it seems that it is not a form issue because I took the SQL statement I used as the record source and created a new query with the sql string. The query behaved the same as the combo box, only listing out local tables.
My current work around is to close the database and reopen, then all is well. Hopefully there is another way to get the linked tables listed without this drastic step.
Don't think it's necessary, but here is the sql statement. Type 6 is linked.
Code: SELECT msysobjects.name FROM msysobjects WHERE msysobjects.[flags] = 0 AND msysobjects.[type] in (1, 6) AND Right([name],7)<>'_SOURCE' AND Right([name],4)<>'_OUT' AND msysobjects.name not in ('tblImport','tblImportFormats','tblUniversal') OR msysobjects.database=gblprojectname() ORDER BY msysobjects.name, Right([name],7);
I'm supporting some Access/VBA code which includes the following behavior:
When an update is made in a (linked) child form, the current date/time is written to a textbox on the main form via
Me.Parent!txtMod = Now
Likewise, the BeforeUpdate event of the main form updates the same field (and then does a bunch of form validity checks, possibly followed by a Save).
When we upgraded to Access 2003 from Access 2000, a problem erupted:
When the user returns to the main form (by clicking on any control outside the subform), the following message is issued: "This record has been changed by another user since you started editing it (etc.)..."
At this point the user must choose between "Save Record", "Copy to Clipboard" and "Drop Changes".
Conceptually, I see why this is happening (though I wonder why Access 2000 didn't flag it). The subform is the "other user". When the main form is returned to, it is "Dirty" (unsaved update), so the main form's BeforeUpdate event fires, and attempts to update the field again (Me.txtMod = Now). Since there is a pending change to the field, an error dialog pops up.
As a quick fix, I replaced the code in the subform with a flag ("Hey, I've been updated!"), which the main form checks on the Exit event of the subform control. But that seems a horrible solution. Surely there's a better way?
Notes:
1. It would be preferable to have the timestamp updated right away by the subform, though having it updated when the subform loses focus is better than nothing.
2. Since a subform is a control from the main form's perspective, I'm surprised that a change to that control doesn't render the main form "Dirty". I guess from a database standpoint it makes sense (the form's table isn't getting updated at all; just the subform's). But then, how does the main form know that the subform has been updated?
3. I tried catching the error via Form_Error. I can make the dialog not appear via "Response = acDataErrContinue", but unfortunately it defaults to dropping the changes (old and new), rather than saving the new.
I have a main form that the user will enter data. Once they hit a submit button, it saves the record and I was hoping it would also refresh the form in which is populated by a query. The form that is linked to a query will be displayed on a monitor 24/7. It will display pending orders. So I was hoping as new orders are placed, the query would display them without needing to be closed and then reopened.
Here is the method I'm using but it's not working.
I need to requery a subform from a third form and can't seem to get it to work.
frmForm1 has frmAddress as a subform. The button cmdReviseAddress opens the form frmUpdateAddress where all of my validation work is done and the new record is added.
However, the new address is not being displayed in the subform.
If I use the command Forms![frmTest]![frmAddress].Requery it works fine.
The problem is that I want to be able to frmAddress on any form, and need to pass the name of the main form (in this case frmForm1) as a variable.
If lsTemp = "frmForm1", the statement Forms![lsTemp]![frmAddress].Requery (and every variation using brackets and quotes that I can think of) fails.
In the default property of a subform control I want to use a control of the main form without using names of forms, but using me and parent.
I used in default property of cboVATDetail: =Me.Parent!cboVAT, but it is not accepted. My aim is to use cboVAT of parent as default in cboVATDetail of child.
frmTaskTracker -subfrmInbox (Datasheet View - based on a query)
frmUpdateInboxItem
subfrmInbox displays a summary of tasks on a task list. The user navigates to frmUpdateInboxItem from frmTaskTracker. After updating a record from frmUpdateInboxItem, it is possible that it the record in question will no longer meet the requirements to have it listed on subfrmInbox.
I have attempted to add code to the on close event of frmUpdateInboxItem to requery the sub form on frmTaskTracker but am not getting the syntax correct.
correct my code? Alternatively is there is a more correct way to do this, I'd be happy to learn it.
Code: Option Compare Database Private Sub cmdClose_Click() Me.[frmTasktracker]![subfrmInbox].Requery DoCmd.Close acForm, "frmUpdateInboxItem" End Sub
I have been trying to figure out how to make a form refresh after deleting a record in a subform. The code in the combo box that populates the subform works fine. If you select the "Action" of "sign" from the unbound combo box above the subform, it places "Sign" in the the subform and then makes a checkbox on the main form [WillTake] = True.
But when I delete the record by right clicking on the entry, the focus is sent back to the main form so I can refresh the form and thus update the [WillTake] checkbox. I have tried just about everything. I can get the focus to a field on the form, but I cannot figure out how to refresh or requery the form.
The code to transfer focus is on the OnDelete of the subform.
I have two subforms on a "Page"/Tabs. Subform #1 is a continuous form which accepts data about dimensions of a pattern piece. The other subform needs to update its information display each time the last control of the first subform loses focus, because it tells me how much material is required for all pieces of this pattern that are entered.
My first feeble attempt at this was to add the following code to the "Lost Focus" event of the final control on the first subform: Form.Parent.Refresh
This succeeded in forcing the second subform to re-run its calculation.
However, after the recalculation took place, I wasn't able to move to the next record on the first subform. This subform is a continuous form, and I need to be able to add another row of data and then see the second subform change based on the additional information in the first subform.