I have a query where I make a calculation. In some cases this calculation results in a division by zero. The field will then show #Fout (#Error in english?). I want to replace this message with something else, like a dash for example.
I have a database which is used by operators to input manufacturing data i.e. LotNo, Customer, SalesOrderNo, PartNo, LineNo, ActualQty, Length, ScrapMat, (MatStdCost), StdLineSpeed, SetupTime, RunTime, LostTime and weightperpiece.
We then use this data to produce information like Standard Run Time: (([ActualQty]*[Lenght])/[StdLineSpeed])/60 Machine Efficiency: ([Standard Run time]/[Runtime])
these work fine if values are inserted. The problem is that when a value is zero it returns a #error value in the field. This is probably caused by dividing by zero which can happen.
A test may occur where there is zero StdLineSpeed etc.
Is there any way I can bet access to return zero in these cases instead of the #error because I wish to do further calculations on totals and averages and I cannot if even one #error occurs.
Having set a table short text field to 'Indexed (No Duplicates)', I have a form which produces a '2105 runtime error' when the user attempts to submit a duplicate value. I would like to replace this default error message with a more user-friendly MsgBox.
My code for the SaveRecord button is:
Code:
Private Sub SaveRecord_Click() DoCmd.GoToRecord , , acNewRec MsgBox "Record successfully saved", vbOKOnly + vbInformation, "Record Saved" End Sub
My code to capture the 2105 runtime error is:
Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer) If DataErr = 2105 Then MsgBox ("This villa booking has already been logged.") Response = 0 End If End Sub
Unfortunately when the save button is clicked (when attempting to save a duplicate value), the 2105 error still runs. What are I doing wrong?
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"
I have form that uses a query as its datasource. In this query, there is a column for Body_Height. From this value for Body_Height, there is a calculation made inside the query, e.g. Body_Height / Body_Mass = Body_Calculation Then, there is a textbox on the form, which uses the calculated value Body_Calculation from the query. However when Body_Height is empty, the term "#Error" appears in the textbox. (Actually "#Fehler" - German for error - appears there as I am using the German version of Access.) I know it is an error, as the data for Body_Height is not yet available and has not been entered into the db yet.
My question: Is it possible to replace the term "#Error" with something user-defined, like "N/A" or "Not available" ? It will just help make the form look a bit better in the end I think.
Please help me as I am still a bit unsure how to do this. :confused:
Now when you select time frame, it works fine. However I also have "Closed Sale" and "Lost Sale" in that list as well and when chosen i get this "#Error" because its text.
How can I replace the #Error with a N/A for not applicable.
I tried:
=DateAdd("m",[Time Frame],Now()) & IsError("NA")
Better yet:
If "Closed Sale" is chosen is there a way to put that in the "Estimated Closing" area along with "Lost Sale" if that is chosen as well.
I have tried putting vbcrlf and "NN" as parameters into this but it doesn't work (maybe it can't see vbcrlf as a separate word!)
Function ReplaceWord(strText As String, _ strFind As String, _ strReplace As String) As String
' This function searches a string for a word and replaces it. ' You can use a wildcard mask to specify the search string.
Dim astrText() As String Dim lngCount As Long
' Split the string at specified delimiter. astrText = Split(strText)
' Loop through array, performing comparison ' against wildcard mask. For lngCount = LBound(astrText) To UBound(astrText) If astrText(lngCount) Like strFind Then ' If array element satisfies wildcard search, ' replace it. astrText(lngCount) = strReplace End If Next ' Join string, using same delimiter. ReplaceWord = Join(astrText) End Function
i have a table that has a column containing a letter reference a / and then another reference ( EG. AAA/A56457A, ght/6577654ghf, etc ) and i want to replace the / with a _
whats the easest and quickest way to do this as an expression
Need a little bit of help, I have a report I pull out of an inhouse system with sales, shortages etc. I want to use a query to alter the formatting slightly and append it in to a different table. Most of this i can do fine, except for one thing.
Two of the sales fields in my report I'm uploading come out in the following text format: 19.0PC 27.0PC 45.0PC etc...
I need to change this before appending as its going in to a number field, all i need to do is lose the PC, e.g. 19.0 27.0 45.0 etc...
I can do this manually, it's a simple find and replace in excel before uploading, gowever I want to automate this as much as possible. Looking around I'm pretty sure it can be done in a query using the REPLACE function but I'm unsure on the formats to use.
The only other thing is once its converted even though it will visually be a numbe (e.g. 45.0) it will still technically be a text field, will this prove a problem on the appending?
I am currently working on a project where i need to try and compare a list of organisation names held by my organisation and another organisation (around 20000 records each).
To take into account differences in how the organisation names may have been entered I'm wanting to strip out things like ltd, limited, company, co, &, and , and so on. I've tried using IIf and replace which works ok if the organisation name only contains one of the substrings I want to replace but not if contains more than one.
How do i go about doing multiple replaces in the same string?
Hi, i have a table of data, with a user name, and a task.
Each user is assigned many tasks, i and i would like to create a query that replaces all instances of a certain name with another name. How would i do that?
We do alot of find and replace in our main form (CTRL+F). The glitch is that once the pop-up box for "Find and Replace" appears, we almost always have to change the search setting from "Whole Field" to "Any Part of Field". Is there a way to set the default to "Any Part of Field" instead so that we don't have to change the setting every time?
I have a combobox called ‘SupplierList’ full of suppliers that the user can choose from. Then I have a listbox called “SupplierQuery’ which is empty. The user will double-click on a name in ‘SupplierList’ to add the suppliers that they want to include in some future query. I have this as the event procedure so far:
Private Sub SupplierList_DblClick(Cancel As Integer)
This works insofar as it adds the double-clicked name to the ‘SupplierQuery’ listbox. But it replaces the previous double-clicked name with the newly double-clicked name each time. How can I make so that it adds each newly dbl-clicked name - forming a list of names in the listbox - instead of replacing the previous entry? If possible, I would like it to get the listed results directly from a table through a query.
having a problem with a query, its used to export data to a txt file for another program.
the problem is i have a field that i format with end of line chars between entries in the field, so in access it looks like a few entries rather than one field (there were reasons for this).
when it comes to export this data, i need to remove the end of line chars with spaces.
heres the part of the query i need to fix: Description: IIf(InStr([Order_data].[Stock2],Chr(13)),Replace([Order_data].[Stock2],Chr(13),Chr(32)) & Replace([Order_data].[Stock2],Chr(10),Chr(32)),[Order_data].[Stock2] & " " & IIf(nz([Order_data].[Stock3])<>"",IIf(InStr([Order_data].[Stock3],Chr(13)),Replace([Order_data].[Stock3],Chr(13),Chr(32)) & Replace([Order_data].[Stock3],Chr(10),Chr(32)),[Order_data].[stock3]),""))
yes that is nasty.. but simple to understand. 2 fields get combined for output (stock2 and stock3), i check first if they need to have chars replaced, then replace if necessary. the output i get though doesnt seem to be replacing the chars, it finds them there with the if however.
I have a list of dates of births in a table, but the way they are always imported (from some piece of crappy software somewhere) is in the format of: 01.01.2005 (using full stops).
Access doesn't like this, and insists on slashes, or dashes. Now, if I do a find/replace, it works perfectly, just replacing all the full stops with slashes. However, I want to do this quite regularly...any ideas how to do it programatically in VBA?
I'm currently migrating a lot of Excel processing to Access and really enjoying the transition. I am, however, having big problems with the Replace function in Access.....
In Excel I use a macro to relace anything in a cell contents that follows a space with nothing......i.e. replace " *" with ""
The fields that i need to do this on do vary in length- they are product descriptors.....e.g
abcdefg 123456 xzy 987
The replace feature (ctrl + h) in table view will do this correctly if "any part of cell" is specified in "match" selection but I cannot seem to replicate this in a query.
I'd be grateful for any suggestions here. I thought about exporting the fields in the columns to Excel and doing the replace there, but I can't get it to work. Similarly I tried writing some VBA for this, but again no joy!
I have my main table and one column is a lookup field to another table.
One of the options that was in the dropdown needed to be changed. So I changed the dropdown, but now I need to change all the old entries to reflect this change.
I opened the main table, and thought I could do a find/replace. But it doesn't work. If I do just a 'find' it finds the old text just fine. But if I do the Find/Replace option, it says the 'look for' text was not found. Even tho, I just found it using the find option. If I click on the tab that says find, it will find it again. If I click on the find/replace it can't find it.
any ideas on a way to quickly replace my text in these fileds, without having to go 1 by 1 through each record.
Hi, My company has renamed a product. I want to find all the records in all the tables in my database that might have the old name, and replace with the new name. What's the easiest way to do this?
I don't really want to have to manually open each table and do a find.
I can write code to go through all the tabledefs and do a find on each one, but the only way I know to do that is by telling it the field name, and field names where the product name might exist vary.
I suppose I can tell it something like for each TD in tabledefs for each F in td.fields {search and replace} next f next t
Is this really the best way? I have a program called SpeedFerret, which I thought would do this, but it apparently only searches the table names, not the actual records in the table.
Hi all! I'm experiencing an apparently simple problem, but it's taking me too long to solve :confused: Two tables with a "text" (100) column on each. I want to select those who are identical. ¡So easy! thats the where clause:
AND a.sDesEntidad = b.sNombreLargo
That works fine. But... i want to "relax" the clause, by not considering dots ( . ) when comparing, and i do like this:
AND (Replace([a]![sDesEntidad],'.','') = Replace([b]![sNombreLargo],'.',''));
and i get a run-time Error 3464, Data type mismatch in criteria expression. Oooops! My access version is 2003, spanish. I would really appreciate ur help, since this matter shouldn't be keeping me busy for so long :( Regards and thx in advance! Alejandro