Modules & VBA :: Replace Values By DSUM
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 Replies
ADVERTISEMENT
Dec 6, 2013
I would like to replace missing TRP information from Query LF with average TRP information coming from Query LF_Average.
Somehow it doesn't work.
Code:
Public Sub Replace()
Dim strSQL7 As String
Dim qdf7 As QueryDef
strSQL7 = "SELECT LF_QUERY.*, LF_AVERAGE.Average_TRP_EUR " & _
[Code] .....
View 14 Replies
View Related
Jan 12, 2015
I have a table (tblConversions) that I'm using as a base for replacing values in a different table. tblConversions is set up as such and is made up of nearly 100 records:
ID LABEL CODE
1 Ashaway ASH
2 Barrington BAR
3 Bristol BRI
4 Jesse Smith BUR
....
Another table (tblSysItemLoc) has nearly 1,000 records with a field for Location Names such as Ashaway New Books, Ashaway Fiction, Ashaway Non-Fiction, Barrington DVDs, Barrington Reference, etc. Other fields in this table are just statistics.
What I need to do is loop through tblConversions, and find in tblSysItemLoc where the Location field Starts With the value from tblConversion.LABEL and replace the Entire field with the CODE. For example, from tblSysItemLoc "Ashaway New Books" gets changed to "ASH", "Barrington Reference" gets changed to "BAR", etc.
I feel like I need a loop inside of a loop, but I'm not sure where to begin. Loops are not my specialty.
View 10 Replies
View Related
Jan 10, 2014
I am trying to do DSUM as a control in the footer of a report which would sum up values in one field [Charge_Qty] only if certain criteria are met for another field [CPT_HCPCS_Code]. The problem is that I cannot use the proper syntax for the multiple criteria but am successful if I only have one value in the criteria. ok this works below but I need to use multiple values such as 93303 - 93321, 93662, 93350-93352
=DSum("[Charge_Qty]","DIVISIONQueryDATEYEARTEMPLATE","[DIVISIONQueryDATEYEARTEMPLATE]![CPT_HCPCS_Code] = '93303'")
View 2 Replies
View Related
Sep 30, 2014
I'm trying to filter from dsum criteria the two values, here is my code :
Code: =DSum("Amount","qry_sumawpo","[Status] = 'FBLNG'" OR "[Status] = 'BLLD'")
How to correct this code. I need 2 different values in 1 criteria.
View 2 Replies
View Related
Apr 28, 2007
I have a text box in a report, with it's control source property set to =[BegDt].
Upon loading the report a message box pops up and asks the user for the value of [begDt]. This occurs 3 more times for 3 other parameters.
Now I want to change the design of the report so I decided to put these 4 parameters on a form so the user can fill in the 4 values all at once rather than responding to 4 message boxes that pop up when you run the report.
The problem is now the control source properties in all the different text boxes need to be changed to [forms]![frmABC]![txtBegDt] etc.etc. There are over 100 text boxes in this report that make reference to the 4 different parameters.
Is there a replace command I can use to change all the occurrences in the text boxes or perhaps a simpler way would be to pass the values to the report through code.
I tried placing this in the report header's format event and it doesn't seem to have any effect.
Code:Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)begytd = [Forms]![frmABC]![txtStDt]endytd = [Forms]![frmABC]![txtEndDt]curmo = [Forms]![frmABC]![cboMo]curyr = [Forms]![frmABC]![cboYr]End Sub
I should mention that the report uses a table (tblRecap) as it's record source. I tried using a query that refers back to the form for the parameter values but that means I have to use the query as the reports record source and that creates a problem because the report needs fields from the table to perform calculations.
Can someone help me with a solution please.
Thanks for your time.
View 2 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
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 4 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
May 6, 2014
I have this working query:
Code:
INSERT INTO TB_SISTEMAS ( LOGIN, SISTEMA, PERFIL, DATA )
SELECT Left([dbo_BACKUP_ACESSOS.LOGIN],255) AS LOGIN, dbo_BACKUP_ACESSOS.SISTEMA, Left([dbo_BACKUP_ACESSOS.PERFIL],255) AS PERFIL, dbo_BACKUP_ACESSOS.DATA
FROM dbo_BACKUP_ACESSOS
WHERE (((dbo_BACKUP_ACESSOS.SISTEMA)<>"ACTIVE DIRECTORY") AND ((dbo_BACKUP_ACESSOS.DATA)="2014-03-23"));
But Iwant to be able to use a set of data to be used in the Replace Statement, so I create a table to add each string I would like to have replaced by "nothing", and trying to make the replace query to look there in order to find what to replace.I also created a table where I will list the systems that I dont want in the select, so I removed the "ACTIVE DIRECTORY" and replaced by the colum that have the list of system I dont want listed.This is the result:
Code:
INSERT INTO TB_SISTEMAS ( LOGIN, SISTEMA, PERFIL, DATA )
SELECT Replace((Left([dbo_BACKUP_ACESSOS.LOGIN],255)),[PREFIXOS_E_SUFIXOS]![Valor],"") AS LOGIN, dbo_BACKUP_ACESSOS.SISTEMA, Left([dbo_BACKUP_ACESSOS.PERFIL],255) AS PERFIL, dbo_BACKUP_ACESSOS.DATA
FROM dbo_BACKUP_ACESSOS
WHERE (((dbo_BACKUP_ACESSOS.SISTEMA)<>[SISTEMAS_EXCLUIDOS]![Sistema]) AND ((dbo_BACKUP_ACESSOS.DATA)="2014-03-23"));
The thin is that this keeps asking me to enter the parameter value for "PREFIXOS_E_SUFIXOS!Valor" and for "SISTEMAS_EXCLUIDOS!Sistema"
View 6 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
Nov 10, 2014
Is there a code that will replace the empty fields by shifting the bottom fields up for access? I am planning to write a code that will delete unnecessary items in my database, however, that will cause the database to have "holes" in it.
View 4 Replies
View Related
Jun 26, 2014
I'm working on an eBay uploader access program for Ebay's File Manager
Our description contains line feeds and carriage returns. I have very little knowledge of Vba, and I can t find any tutorials on how to replace the characters with spaces on how to program this.
The table is called tblCustomer
The field is called *Description
I'm using access 2007
View 9 Replies
View Related
Mar 24, 2014
I try to go throgh all columns and replace all blank fields with 0.Somehow this doesn't work:
Code:
Sub TEST()
Dim str As String
Dim rs As DAO.Recordset
Dim fld As DAO.Field
[code]...
View 7 Replies
View Related
Sep 21, 2014
Within my table 'Contacts' I have the field 'City' which as you would expect contains the city.
The data in the City field which is sourced from the web can often merge two regional municipalities into 1 and I know through digging in behind the data what the correct answer should be.
I am looking to accomplish a list of edit replaces that takes 30 + edits and automates.
Change "ClevelandAkron" to "Cleveland"
Change "Dublin 2" to "Dublin"
Change "Greensboro/Winston-Salem" to "Greensboro"
etc. etc.
There are 10,000 plus entries in the table of which many are correct.
View 2 Replies
View Related
Sep 23, 2014
I have a split database. When the front end db is updated, i am attempting to delete the end users copy and replace with the updated version.
I have gotten as far as being able to open Database A, Open Database B with A and Close Database A, but it will not let me delete Database A from B because the procedure originated from Database A.
View 11 Replies
View Related
Jan 23, 2015
I have 4 tables with a field that holds a "batch number" there can be many batch numbers in these fields.I want if possible to replace a batch number from all my tables that contains that data and replace it with another batch number in one go. is a macro the only way to do this.I would like a macro that asks me the batch number to replace and then asks me the number to replace it.
View 14 Replies
View Related
Jul 30, 2015
How i can cancel the a carriage return and replace with a tab or stop it moving down my subform and make it move the the next field instead of going to a new line.
I am using the Keydown but don't know how to cancel it, it just bring an message but it stops it moving to a new record,
Code:
Private Sub Barcode_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
MsgBox "rtn pressed"
End If
End Sub
End If
View 5 Replies
View Related
Dec 18, 2013
I have a table called: "tb_special_characters" with a field name [character]. In this table are values that I would like to remove from fields in another table ("tb_data", field name [Title]
The values in the "tb_special_characters" are thinks like
.
@
}
I'd like to run a query on tb_data.title that would replace any matching characters in tb_special_characters.character with nothing (I remove and close any spaces).
View 2 Replies
View Related
Feb 13, 2014
I need to replace the embedded image on a large number of reports and forms. I'm looking for a way to loop through all of the controls in my forms and reports and if the control is an image, replace the embedded image with a new one. Can this be done using vba?
View 5 Replies
View Related
Jun 11, 2014
I am trying to use the string value from a form control as the criteria for a query. I first need to replace the "," in the string with "AND".
So far I have a module using the Replace function, but it doesn't seem to be working. I am not sure I can reference the string inside the form control directly....if I can, I might have a syntax error.
Here is my code so far:
Dim result As String
result = Replace("Forms!Processing!Dataset_Acreage_Query", ",", "AND")
I am not experienced and having trouble finding the search terms to answer this question.
View 1 Replies
View Related
Aug 2, 2007
Hi everyone,
I have a a table called [Email Database] with many fields
I need to create a query that replaces all Null values with blanks or ""
I'm not that familiar with SQL so any help would be appreciated!
View 1 Replies
View Related
Jun 12, 2015
We have a spreadsheet that i upload onto a table, i use on of the fields to build a file path but if there is a special character it causes problems,i need to replace the below with spaces if they are in my field called path
< (less than)
> (greater than)
: (colon)
" (double quote)
/ (forward slash)
(backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)
. (full stop)
, (commer)
how i can do this in some sort of update query.
View 1 Replies
View Related
Jun 17, 2013
How do I direct the ZipFilePath and ZipFolderPath to use a directory I define in a textbox in a form? Instead of hard code like it is now?
Option Compare Database
Option Explicit
Public Sub NewZip(ZipFilePath)
On Error GoTo Err_NewZip
Dim lngFile As Long
lngFile = FreeFile
[Code] ......
View 2 Replies
View Related
Aug 11, 2015
I have a database that I've split and have deployed to 7 persons.
The thing is, I have three (3) forms:
Form 1
Form 2
Form 3
...that require changing a portion of a line in each form's respective VBA codes. I need to change the directories to where an excel workbook is stored after exporting, and another is where same excel is moved to after being uploaded.
At the moment, during deployment I have to manually change the directories.
I was thinking of maybe a pop-up form with four (4) fields that allows the user to select his/her name at the start-up of their frontend app, and paste the directories in the other text boxes provided.
This information will then be used to replace the directories in the VBA.
If I were to make changes and have to redeploy, I would have to do everything manually again.
View 6 Replies
View Related
Aug 4, 2014
My company recently upgraded our MS Office from 2007 to 2010 (except for Access).
Previously, when I had Access 2007 and Outlook 2007, I had a process that generated 50+ dynamic emails from an Outlook template file (.oft).
The code would loop through a listbox and replace the template's default text to a string of text specific to the selection in the listbox by utilizing the Replace() function on the MailItem .HTMLBody.
Since the upgrade to Outlook 2010, the code is able to run, however, the Replace() function is no longer working; Instead, each email that is generated maintains the template's default text.
The only thing that is not working is the Replace() function, all other aspects of the code work fine.
I've provided a simplified version of the code below:
Dim myOlApp As Outlook.Application
Dim objMailMessage As MailItem
Dim stBody As String
Set myOlApp = Outlook.Application
Set objMailMessage = myOlApp.CreateItemFromTemplate("C:UsersDesktop emplate.oft")
[Code] .....
I've recreated the template file in Outlook 2010, thinking that the template created with Outlook 2007 would be the culprit, but to no avail.
What could have changed from Outlook 2007 to Outlook 2010 that would render my previously valid code ineffective?
Are there certain references I need to enable in both Access and Outlook to allow VBA in Access modify the content in an Outlook email?
View 12 Replies
View Related