Forms :: Delete Records In Subform Based On Check Box In Parent Form
Mar 1, 2015
I have a parent form and connected to it is a subform. On the parent form I have a checkbox which enables and disables fields on the parent form and also hides the subform.
What I want to do is when the user unchecks the checkbox, this action also deletes the associated subform records, if there are any.I'm sure that this can be done with an SQL Delete query in VBA.
View Replies
ADVERTISEMENT
Jul 23, 2015
I have a parent form which has a yes/no checkbox in the form's record source. Then in that parent form I have a sub-form. If NO records exist in the sub-form I want the checkbox to be UN checked. If records DO exist in the sub-form, I want the checkbox to be CHECKED.
But I want this to happen as records are added or deleted from the sub-form. In other words, if the parent form is opened and no records exist in the subform then the checkbox should be unchecked. But as soon as the first record has been entered in the subform, the checkbox on the parent form should be checked. Likewise, as soon as the last record has been revoved from the sub-form, the checkbox on the parent form should be unchecked.
What code do I need to accomplish all of this?
View 1 Replies
View Related
Jun 28, 2015
I have a form with 22 subforms (in about 11 tabs). Each one of these subforms has a controlling field in the main form (table) that dictates if the associated subform needs to comply with data entry rules or not.
For example:
Field in main form cboMed (Yes; No)
Subform: frmSubMeds has a list of medications
I want to be able to loop through all the records of the subform and determine if they are complete.
This check is run from a command button; that should also consider the value in the combo box. i.e. Check only if the combo has a value of "Yes"
Since i have 22 subforms and have to run the check on everyone of them, i have used the tag property to check if the record is blank or not. This is what i have so far
Code:
For Each ctl In Me.Controls
Select Case ctl.Properties("ControlType")
Case acSubform ' only look for subforms
If ctl.Enabled Then
If Not (IsNull(ctl.Properties("SourceObject"))) Then 'if it is a subform type
[Code] ....
The problem with this is that it only looks for the selected record in the subform and doesnt look for ALL the records.
View 5 Replies
View Related
Dec 6, 2013
What I have is a form that takes in information regarding test data. Each test run can record data for multiple requirements. I am able to pull all data fine, however in order to make it easier on the user i was hoping to populate the requirements subform based on a selection of "test group" in the main form.
Commonly run together requirements can fall in to groups. I have a selection box for these groups in the main form and a table that stores these group id's and group setup. Is there a way to autofill the tables records that the subform is linked to based on the selected test group?
View 3 Replies
View Related
Apr 30, 2015
I've got a Parent form (frmProspectDetails) with a subform linked (fsubProspectSkill).
This form is for users to enter general information on a prospect (names, position, height, weight, etc) on the parent form and skill levels on the subform.
Currently the subform is set so the user has to manually select the specific skill set for the prospects position, and then enter a value for each skill level(1-99).
I'm trying to get the subform to auto populate with a specific skill set based on the position selected in the parent form, so the user only needs to input the skill level without selecting each specific skill.
This data is then stored in a table (tblProspectSkill)
To add, I've created a form (frmPosition) that lists the specific skills set for each position.
I'm not sure how to get this subform (fsubProspectSkill) to auto populate with the specified skill set from frmPosition.
View 6 Replies
View Related
Jul 17, 2013
I have a form with a subform in a navigation menu. Something like:
Navigation Form
NavigationSubform
ParentForm (header data and some unbound calculation fields)
Subform (Multiple lines tied to query)
I have some fields in the ParentForm (i.e PF1, PF2) that would effect the values on the Subform (i.e. SF1, SF2). Also, there are some user editable values on the subform that will calculate the remaining fields on the subform (still using data from parentform).
My calculations work fine for the changes made on the subform. However I need to be able to calculate all the children lines on the subform when the form loads or a change is made to certain fields on the parentform. My On_Current event only wants to recalculate the first line.
Parent Form
PF1=10
PF2=3
Subform QTY ADJ SF1 SF2
Line 1 5 .05 10.6 112.89
Line 2 8 .14 10.38 105.15
...
Line N
SF1=PF1+(PF2/QTY)
SF2=SF1*(SF1+ADJ)
So if PF1 or PF2 were changed then all the lines is subform would recalc SF1 and SF2. If changes were made to QTY or ADJ, then that line would recalc SF1 and SF2.
View 3 Replies
View Related
Jun 24, 2013
I have a form to enter archaeological features in a feature table. Each feature is present in one or more archaeological strata, for which I have a stratum table. There are 41 strata in total named 1A, 1B, 2A etc. On the form I want a checkbox for each of these and then to make it add a record to the stratum table for each of the selected strata. The stratum table and feature table are connected by the feature_primary_ID (key in feature table), so when making a new record I need this primary ID and the respective strata to be entered in the fields.
At the moment I've got something like this:
Code:
Private Sub Check1_Click()
If Check1.Value = True Then
DoCmd.RunSQL "INSERT INTO tbl_FEAT_STRAT (feature_primary_ID, stratum_ID) VALUES ((feature_primary_ID of present record),Label2.Caption)"
Else
DoCmd.RunSQL "DELETE FROM tbl_FEAT_STRAT WHERE feature_primary_ID = (feature_primary_ID of present record)"
End If
End Sub
For starters, I dont know how to get the feature_primary_ID from the features table (also represented in the form as a field) and use it to make a new record in the strata table.
Second, when using this code I need a copy for each of the 41 strata checkboxes. Creating lots of redundant code. Easier would be a generic code that loops through all the checkboxes after they've been checked and then add new records for each of the checked boxes. Tried something with a command button, but couldn't get it to work.
View 14 Replies
View Related
Jan 10, 2014
In the detail of the parent form, there is a tab control block and each has subforms on them that are exactly alike for WorkOrder Notes, History, Specs When the Work Order subform is accessed (connected by SerialNumber, WorkOrderID and CertDate) the default WorkOrderID should default from the parent form, the SerialNumber should default from the parent form, and the CertDate should also default from the parent form.
What is the syntax to get these fields to default to the values parent form BUT not specifically referencing the name of the parent (because there are 5 differnt parent forms)?
View 6 Replies
View Related
Mar 30, 2015
Parent form/table, with a subform (separate table, 1:M link on "ID") The parent form data stays fairly constant (occasional change/update), with multiple entries in the subform for each parent record which are added to more frequently The master table has a field "last interaction" which I need to update whenever a new entry is made in the subform/subtable It updates fine when I change an entry in the parent table/form, but not when I add a new subentry for that parent
View 12 Replies
View Related
Dec 10, 2013
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.
Obviously I've done this wrong.
View 1 Replies
View Related
Nov 23, 2013
I have a form Delete which contains four fields i.e. Date, City, Depots and Vendor, which has combobox.
I am trying to delete a record from table "Sheet1" based on the combobox, for which i have written the following code, but getting an error at the lines highlighted in red :
Private Sub Command30_Click()
On Error GoTo Err_delete_Click
Dim stDocName As String
Dim intResponse As Integer
intResponse = MsgBox("Are you sure you want to delete this record?", vbYesNo + vbExclamation, "Cash Management Team")
Select Case intResponse
Case vbYes
CurrentDb.Execute _
[Code]...
View 9 Replies
View Related
Dec 12, 2013
I have a form to add, edit, and delete Records from a table. I am using the following VBA
Private Sub cmdEdit_Click()
If Not (Me.frmlEmpDetailsSub.Form.Recordset.EOF And Me.frmlEmpDetailsSub.Form.Recordset.BOF) Then
With Me.frmlEmpDetailsSub.Form.Recordset
Me.txtAddEditname = .Fields("Name")
Me.cboRoster = .Fields("Roster")
Me.cboPermFctn = .Fields("PermFctn")
End With
End If
End Sub
Instead of referring to the Subform to load the data i would like to refer to a combobox:
cboSearchName
Its not an issue but This Combobox contains 5 columns...
View 2 Replies
View Related
Jan 26, 2014
I have two subforms on a main form. Both use similar queries and nearly the same set of records and PK. The first subform is for data entry and the 2nd subform is a continuous form that lists the entries in order that are made from the 1st Subform. (for entering in vacation days and appointments)
The continuous form cannot be edited, it is to be a list for viewing the information only.
I have an edit button next to each record on the continuous form. When the button is clicked, I want it to take the 1st subform to that specific record as well (same PK), so the information can be edited there.
I cannot figure out how to get the 1st subform to go to the record on the continuous form when the button next to that record is clicked on the continuous form.
I tried the DoCmdSearch for record and just keep getting object is not open errors.
View 2 Replies
View Related
Jun 20, 2013
I have a listbox on a subform (or a subform within a subform).
When it is clicked I want all other listboxes to unselect.
There may be listboxes on the mainform, on other subforms, on other subforms of subforms.
I imagine I'm looking at a recursive function of some sort, but I'm not entirely sure of syntax to identify parent and children forms...
pseudocode so far:
loop all controls
if control = listbox, unselect all
if control = subform - recurse: loop all subform controls
if control = parent... err... Fail.
View 3 Replies
View Related
Jun 2, 2015
I have a parent and sub form in dataset view.
What I would like to do is prepopulate the subform with data from the parent form when I create a new item of data..
i.e.
When I click the "+" button Field1 on my subform is populated by Field1 on the parent.
I have tried beforeupdate on both the subform properties and the subform.Field1 properties.
View 3 Replies
View Related
Jun 5, 2015
I want to force an autonumber field on a parent form to start a new record when clicking on a subform, so that value can be passed to new records in the subform. Is there a simple way to do this?
I'm using Access 2010. I have a parent form based on a query that does not have any fields intended for input but has an autonumber ID field. The subform is based on a query that finds records based on the ID field in the parent. When the parent ID field has a value it works perfectly, including adding new records in the subform. When the parent ID field is blank, though, I can add new records in the subform but the ID field does not populate.
I made a workaround by adding a Yes/No field to the parent and its query that users can click to create a new record, so the ID field has a value to pass to the subform. This works fine, but I feel like there should be a better way to do this without user clicks.
Via VBA, I've tried setting the parent form to dirty, and setting the Yes/No field to Yes, along with a variety of less likely candidates like refreshing and requerying. I've tried the above on various events including the parent LostFocus; the subform Got Focus, On Click, On Mouse Move; and the same events for control on the subform.
At this point I'm not sure whether the problem is my event choice, or the object method I'm using, or just the syntax for my control references. Or maybe this is actually more complicated than I think and sticking with the checkbox option is the best way to go.
View 6 Replies
View Related
Apr 11, 2014
I have a sub form that shows me a companies history. This subform is used on 2 different Parent forms. The record source for the sub form uses a criteria that looks at a companyID field on the parent to determine which records to return. My question is how do I have the query criteria depend on which form is currently opened? The criteria would look something like this:
[Forms]![frmCompanyHistory]![txtCompanyID] OR [Forms]![frmCompany_Project_Details]![txtCompanyID]
If I open the form with this criteria, I will be asked for a value in txtcompanyID for whatever parent form is not open. How do I properly do this without making multiple queries that are almost identical?
View 5 Replies
View Related
Sep 17, 2005
Hi,
Scenario:
Parent form: An order form (Order table) with data fields like Order ID and etc. In my Order Table, I have a revenue data field, which is a calculated field based on numbers of items in its subform (OrderDetails table).
Since the profit data field is based on the items of the Order Details, for each time the user add an records in the OrderDetails table, it need to be recalculated. Currently, I used a calculated field in the query of the OrderDetails subform and bind it back to the main form, again it bind it back to the profit data field in the Order table.
With this method, everytime user add a record in the subform, the calculated field in the query will reflect the changes accordingly, but I have difficulty to force the changes in the calculated field to update the profit data field in the Order Table. I most of the events (like On Changes, On Dirty ....) on both parent and subforms, it seems does detect the changes.
Please help ...
View 2 Replies
View Related
Jun 27, 2012
I added a text box on my main form. I have to other parent names in a subform that I would like to add to my main form. I have this working just using one parent name "dtdrec" that is working. How would I add "flduser" and "fldstuff".
=[tblPayEstimates Subform].[Form]![dtdrec]
View 7 Replies
View Related
Nov 19, 2014
I have a parent form where I enter a value for tax rate. I need to use this value in the tax calculation in the subform fields i.e. subform.taxdue = subform.qty * subform.price * parent.taxrate.
I can get the value into the field. But I do not think I am putting it in the correct event. The parent form is a sales form and the subform is the sales items form. So there can be multiple items on the sub form.
View 5 Replies
View Related
Jan 7, 2013
I have parent form and child subform. one field in the parentform is calculated on sum of records on the childsubform when the parent form loads initially the value in the calculatedfield is 0 then it shows the correct value when the childsubform value is populated i have another-field i want to change the property of the onotherfield.backcolor= RGB(0,0,255) when calculatedfield.value<0 but its taking the initial value(0) not the calculated onewhich event shall i invoke on the form so that it waits the subform to complete then fires ... i tried current, load, activate events .. with no success.
View 2 Replies
View Related
Aug 4, 2014
All; using 2010. How can I get a subform to grow or shrink based on num of records returned? Its a continuous subform. Tried changing Vertical and Horizontal Anchors as well as some VBA suggestions but havent been able to make any of them work.
View 2 Replies
View Related
Jun 11, 2013
I am updating an existing database and I have a parent/child form and I want to filter the subform for the current parent form record? The two forms are linked together by woWorkOrderID/deWorkOrderID.
View 1 Replies
View Related
Feb 7, 2014
I have a table InvPrice and Updated Pricing
Need to delete all records from InvPrice that Match UpdatedPricing
InvPrice.StockCode = UpdatedPricing.StockCode
InvPrice.PriceCode = UpdatedPricing.StockCode
I have tried something like this...
Dim dbs As DAO.Database, sql As String, rCount As Integer
Set dbs = CurrentDb
sql = "DELETE * dbo_InvPrice Inner Join (dbo_InvPrice Inner Join UpdatedPricing on dbo_InvPrice.StockCode = UpdatedPricing.StockCode ) ON on dbo_INvPrice.PriceCode = UpdatedPricing.PriceCode "
dbs.Execute sql, dbFailOnError
View 14 Replies
View Related
Feb 2, 2006
Hi,
I'm getting really mixed up here, Im trying to delete all records in table products based on the following query;
SELECT products.*, tbl_stage_product_update.[Catalogue No]
FROM tbl_stage_product_update INNER JOIN products ON
tbl_stage_product_update.[Product Code] = products.pID
WHERE (((tbl_stage_product_update.[Catalogue No])="0"));
I've tried using the exists keyword with the previous query as a sub query, but it seems to delete all records form table products.
can anyone offer any advice.
TIA.
Mark
View 2 Replies
View Related
Aug 11, 2005
Well, my newbie status in db development has reared its head. I knew from the beginning I didn't want to have cascade delete when deleting a clinic (parent) from the db. Problem is some queries in other areas need some clinic info and if the clinic is deleted, it won't be available. Right now I'm thinking that an easy way out is only allowing a delete if it has no attached records. If the clinic is no longer used, they can just write in the memo field that this clinic is no longer used. It's not a large db and there won't be hundreds of clinics so it may not be too bad. Any other suggestions?
scratch
View 6 Replies
View Related