Modules & VBA :: DSum Not Working On Subform
Nov 2, 2014
Every time i try to get info from a sub form or its table ,Things never sem to work.Is there something special you have to do for eg maybe going via the main form?I am trying to use dsum as an alternative to multiplying info in the sub form.This is the code
=DSum("SoldAtPrice*Quantity","[Order Details]","IDNewOrders=" & [OrderID FK]).
View Replies
ADVERTISEMENT
Dec 8, 2006
I can't figure out what I have wrong in my code. I've searched all over the forums and the help files in Access. I'm sure it's something simple. Could someone please take a look?
=DSum([DefectQty],"d_sub1_DefectReport","CodeID= "" & [tblDefectCodes].[CodeID] & "" AND ""[InspectDate] >= #" & [Forms]![frmDefectDetailReport]![txtStartDate] & "#" And "[InspectDate] <= #" & [Forms]![frmDefectDetailReport]![txtEndDate] & "#")
I'm trying to get a sum of all defect quantities between a date range from a user form. Rather than summing all the defect quantities for a defect code, it's summing up the total quantites for each quantity. I'm sure that doesn't make sense so here's an example:
InspectDate CodeID DefectQty DSum Should Be
6/1/06 100 1 3 5
6/2/06 100 2 4 5
6/3/06 105 1 3 1
6/4/06 103 1 3 1
6/5/06 100 2 4 5
The domain is a query because the dates come from a different table than the defect quantities, so the query is pulling all the relevant data to be summed.
View 6 Replies
View Related
Apr 17, 2015
I have the following in a query:
Count: Val(DSum("Num","Google_export_1Cancer_Target_Prea" ,"DatePart('m',[StudyEntryDate])<=" & [AMonth] & " And DatePart('yyyy',[StudyEntryDate])<=" & [AYear]))
Our Financial Year runs from April to March.
The formula works fine up to, and including, December. Then, for the last three months of the financial year (Jan, Feb and Mar), the running total of the 'Num' field stops and the entry for January is just January's 'Num' with the running total starting again for February and March.
How do I rectify this?
View 4 Replies
View Related
May 23, 2014
Im v new to VBA and been having trouble getting the following code to loop through the records in my subform:
Private Sub cmdComplete_Call_Click()
Dim rs As dao.Recordset
Set rs = Me.fsub_Call_Off_Quantities.Form.RecordsetClone
rs.MoveFirst
[code]....
It only seems to update the first records txtQuantity_Called_Off value. I have tried all the 'looping' code variations i can find and they all seem to only update the first .
View 6 Replies
View Related
May 12, 2015
I have a navigation form which has two subforms on it (ie 2 tabs linking to different forms). I have got aq filter working for one of the forms but not on the other. This is using
If IsNull(Me.txtoperationscontract) Then
MsgBox "Please type a contract number into the textbox!", vbInformation + vbOKOnly, "Incorrect Details"
Else
Me.OperationsSubform.Form.Filter = "[Contract]='" & Me.txtoperationscontract.Value & "' "
Me.OperationsSubform.Form.FilterOn = True
End If
The problem is that it does not work on subform B because the Contract field does not exist.
View 6 Replies
View Related
Jan 13, 2015
I have a form that uses a listbox. I can select multiple items and then update a subform. When I press a button with VBA and use the filter property on the subform for the first time, nothing happens. When I press the button a second time, it does - and it works thereafter with different selections. It only happens that first time, after loading the form and pressing the button for the first time.
I have tested that the list items are accessible via the vba variables and stepping through my code and the problem starts with the filter properties.
the statement:
Me.sbfrmCluster.Form.FilterOn = True
Me.sbfrmCluster.Form.Filter = strFilter
is not switched on first time (I have tried a requery and refresh statement after this). When I step through the code the first time, the FilterOn property remains false. A second button press and it is fine.
View 2 Replies
View Related
Apr 3, 2014
I have a form with two subforms. One subform is a datasheet that pulls data from a temp table. During the other subforms Form_Current, the temp table is emptied (DoCmd.RunSQL "Delete from tblAddRefs"), reloaded with data relevent to the current record, and requeried (Forms("frmEDFP").Controls("tblAddRefs subform").Requery). This works like I want it to...
With the exception of the initial load of the main form. The subform based on a table shows (#Deleted) instead of data. if I step through the code, I can see that the temp table is emptied and repopulated by the time I try to requery the subform. This is still happening during the Form_Current of the other subform, which is successfully running on main form load.
If I requery (Forms("frmEDFP").Controls("tblAddRefs subform").Requery) using a button on the main form once it is loaded, the #deleted data is correctly is replaced by regular data, so it's like the requery in the Form_Current event isn't doing anything during load.
View 2 Replies
View Related
Sep 11, 2007
I know there are numerous threads regarding dsum() on the forum, but I wasn't able to find the exact answer to my problem.
The root of my problem is that I'm trying to update a field on a table using dsum, which references another query to update the table. Although I have all of the correct keys from the physical table joined to the query in the dsum function, the code/ms access seems to ignore the joins. As a result, all payees are having their "vol" field set instead of a select subset.
Query (GetTxnVolAmtTR"):
SELECT p.payee_id, sum(txn_volume) AS vol, t.market, t.period_id
FROM ft_payees AS p, ft_txn_summary AS t
WHERE p.payee_id=t.payee_id And p.market=t.market
GROUP BY t.payee_id, t.period_id, t.market, p.payee_id;
Update statement (references the query above):
UPDATE tmp_ft_component AS rc
SET rc.volume = Dsum("vol","GetTxnVolAmtTR","GetTxnVolAmtTR.payee_id= " & [rc.payee_id] And "GetTxnVolAmtTR.market= " & [rc.market] And "GetTxnVolAmtTR.period_id= " & [rc.period_id] & "")
WHERE rc.component_name='Total Revenue';
as you can see, I have all of the fields I want joined, but the code seems to ignore this. I've tried looking at this site: http://www.mvps.org/access/general/gen0018.htm , but haven't found my answer. Any help would be much appreciated!
View 3 Replies
View Related
Feb 16, 2015
How to use Dsum Function? Am using below following Dsum functions but they are not working and shown an error result.
=Nz(DSum("[Liters]","[SRB_SubformQry]","[Category]=MILK"),0)
=Nz(DSum("[Liters]","[SRB_SubformQry]","[Category]='MILK'"),0)
=Nz(DSum("[Liters]","[SRB_SubformQry]","[Category]<>MILK"),0)
View 3 Replies
View Related
Aug 11, 2015
I have a subform from which I want to calculate values into a text box on the main form, to keep a running total of weeks for individuals. Using the expression builder to just add the fields, I only get the total for the current sub-form record. If another record is added to the subform, the total reverts to zero, and then it takes that record's input as the total. Which makes logical sense.
I think I need to do a 'DSum' from the subform/table, but I'm not sure how to sum for just the current ID/individual. I have tried to bodge it myself with the expression builder, but it tells me that 'the function contains the wrong number of arguments'.
View 6 Replies
View Related
Jul 19, 2015
I have a from which has a sub Form in it which uses a query of a table which is filtered, In the main form I want a sum of the data in the subform for a particular field if TRUE.
In the main form I have a text field with the Syntax =DSum("[Cost]","RepairInformation","[Labour] =.True."), but this returns an error, I have no issues for the total cost for with I have a Text Box in the subform which returns the Total cost in the main form.
What are my options to have a conditional sum for a particular condition.
View 5 Replies
View Related
Oct 27, 2014
i have an orders form with aorder details sub form.I need a grand total of the order that i need to store in my orders table. Cant seem to make anything to work is this becouse my form is a sub form .Basically i am doing a dsum quantity *sold at price with a where id information.Doi i have to do anything special as the info is in the sub forms table
View 3 Replies
View Related
Dec 16, 2013
I want to replace some values in a TNS_QUERY with DSUM. The error message tells me I have to use an updateable table.
How can I avoid to create a query and replace the values directly in the original table TNS? I just group on the original table.
Code:
Public Sub TNS_QUERY()
Dim strSQL As String
Dim x As Double
Dim qdf As QueryDef
strSQL = "SELECT TNS.[Division],TNS.[Customer_Split],SUM([TOTAL_NET_SALES])
[Code] ....
View 2 Replies
View Related
Jun 19, 2013
Mycode works great when I use the DCount function, but fails when I change it to DSum which errors with: Error 94 - invalid use of null.
dblCntr = DSum("[intEventCount]", "tblResourceEvents", "[ResourceEventTypeID] = " & myKey & " AND [TimeFrameID] = " & Me.cbo1)
The entire table has valid data - no nulls. myKey and Me.cbo1 both have correct values.
View 2 Replies
View Related
Aug 24, 2013
I am trying to use dsum to calculate a sum from either a table or query to display on a form and this needs to be for different services within a period so I am using the following:
Code:
Me.txtTotalEarnings = DSum("Price", "KatiesPeriodTakings", "AppDate" >= CDate([Forms]! _&
[frmKatiesTakings]![txtStartDate]) And "AppDate" _&
<= CDate([Forms]![frmKatiesTakings]![txtEndDate]))
But I keep getting a mismatch error
The Query is called KatiesPeriodTakings
The field I want totalled is called Price
The date field is AppDate and the 2 controlling dates are the Startdate and EndDate from the Form
View 5 Replies
View Related
Mar 3, 2005
I have a main form which is linked through a [PackageID] field to a subform. i wast to use the same form for both shipments in and out. the subform has a list of serial numbers add for each [package id].
On the main form i have addresses ect and then a combo box onthe [PackageID] field which brings up all the serial numbers that came in, in that package.
This is perfect for sending a large container back out unopened, however there are times when the database will need to 'pick and choose' serial no.s from several packages. To do this i made the [SerialNo] field on the subform a combo box - looking up all the serial no.s in stock - however when a serial no is selected it doesn't update the other 15 fields in the subform.
Any sugestions? Got a feeling thats its quite an easy thing to do but its beaten me!
Many thanks
Ed
View 2 Replies
View Related
May 5, 2005
I have a main form with a subform which in-turn also has a subform (in datasheet mode). When the user clicks a button on the main form I want to disable all of the controls on the subforms. This works fine until the user clicks the button while the focus is on one of the text fields in one of the subforms. It rightly complains that the control can't be disbled while it is in focus. To circumvent this problem I've tried setting the focus to another field before disabling the control. However this doesn't seem to work. It seems to ignore the setfocus and still flags the original error. Is it not possible to set the focus of a subform from the main form?
Example:
[subfrm1].Form![Field2].SetFocus
[subfrm1].Form![Field1].Enabled = False
This fails if the focus was in Field1 at the time of executing the code.
Any ideas?
View 3 Replies
View Related
Aug 8, 2005
platform : access (adp) / sql server
Problem : form filter not executing in subforms
When I goto one of my subforms I can activate the form filter.
When executing the form filter no records show up, it just keeps showing my criteria. When disactivating the form filter I receive an error message telling that my view must be misspelled (it's about spaces). My view is called Vw_people , as a record source it works fine so it can't be misspelled.
Is the problem the adp connection or the subform? I don't know
View 1 Replies
View Related
Oct 7, 2005
Heya
Ive got my combos working fine now (thanks to all you kind folk on this forum!) but now that I have opened the main form (in which the combo box form is nested), once I have selected an item in the first one, and then click on the 2nd combo, a parameter box comes up saying "Forms!Training Record!Course_title_combo" and wants a value.
I cant see why this doesnt work when the form is nested, any ideas?
Gazz
View 11 Replies
View Related
Apr 20, 2005
I have an orders subform displaying the line items in an order.
I have two combo boxes in the subform that allow the user to select 'Product catagory' and 'Product'. To enter a product the user must first selct a product catagory which filters the products available for selection. If the exact product is not listed then on option to 'Add new item' must be offered
The problem:
At the moment the combo boxes show the same product catagory on every line of the order, even though each line is different and the second combo box is empty
How do I:
1. make the combo box only display the entry for the line it is on
2. force it to filter the available entries for the second combo box
3. offer an option in the second combo to 'add new item' (if the users selects this then Access should open the products entry form and pass the vale of 'Product catagory' from that line as a parameter to preset the form.
other info:
The data for the subform is generated by a query on 3 seperate tables all linked by relationships.
(tblProductCatagory, tblProducts, tblOrders)
The combo boxes are unbound
Thx.
Kev.
View 10 Replies
View Related
Jul 1, 2013
I have an IIF function specified on a continuous sub-form as below - basically it checks to see if the value of two text boxes is equal, and if they are it displays 'And', if not it displays the value of the column EntitlementName. I'm trying to work around grouping not working in continuous forms.
When I view the form directly it works no problems but when I view the form as a sub-form instead of showing the correct output it shows #Name? Both the text boxes I refer to have the correct values in them.
=IIF([txtPrevValue]=[txtValue], Format("And"),Format([EntitlementName])
View 2 Replies
View Related
Apr 23, 2014
I have a subform that has the Expense Code from the Expense Codes Table and I want to look up the Description (yes I know its not correctly spelled in the formula but it is in the table)
=DLookUp("Expense Discription","Expense Codes","Expense Code=" & [ExpCombo])
But I keep getting "error" returned
I have double checked spelling field names etc...
View 6 Replies
View Related
Apr 11, 2014
When I click on a record on the subform and right click to get the delete record option nothing happens in FORM view but works in DESIGN view.
I have checked all the record and form options and they are all correct.
Using Access 2010
View 3 Replies
View Related
Nov 28, 2014
I have a cascading combo box working fabulously in a form. However when I embed that form into another form, the cascading combo boxes quit working. After doing some searching around on the web I think my issue is either in the query that the dependent combo box references and/or in the "after update event procedure" but I just can't seem to figure out the exact changes to make to my database. Details:
Tables with data for combo boxes:LOOKUP TABLE - Veg Species - Species Type,
LOOKUP TABLE - Veg Species - Species Name.
Related together based on common field: SpeciesType
[code]...
When the form with the combo boxes is embedded as above, I can select the species type from the dropdown but when I try to select the species common name value I am asked to
"enter parameter value - Forms!SUBFORM2a - Enter Specific Veg Info!cmbSpecies_Type".
View 5 Replies
View Related
Sep 11, 2012
I have a subform that is in Datasheet view. If I open this subform on it's own, the Date Picker works for the Date field. However, if I open the main form with the subform on it, the date picker doesn't work? Nothing happens when I select a date on the calender.
I am using MS Access 2010.
View 1 Replies
View Related
Mar 17, 2014
I have two command buttons in a subform "sbfScoutRegDetails", one that launches a report and the other attaches the report pdf to an email, associated with the record ID when clicked.
Both of these buttons work fine when just the subform itself is open, but when viewing it in its main form, I get a window saying 'enter parameter value' for "Forms!sbfScoutRegDetails!ID" (this is the WHERE condition in the macro).The report then opens with all the record information blank.The full WHERE condition
Code:
[ID]=[Forms]![sbfScoutRegDetails]![ID]
Not sure if it's because of using a continuous form as a subform? I need the user to be able to view/print or email a contract to each group/contact that signs up.
View 5 Replies
View Related