SELECT Adresses.RawDat a
FROM Adresses
WHERE (((Adresses.Raw Data)=InStr(1,[RawData],Chr$(13))));
Its not doing the trick for me and I'm not sure why. 6 1680
MLH wrote: SELECT Adresses.RawDat a FROM Adresses WHERE (((Adresses.Raw Data)=InStr(1,[RawData],Chr$(13))));
Its not doing the trick for me and I'm not sure why.
That's a very strange filter. It appears you are only looking for
records where RawData is equal to the position where a Chr(13) exists.
Maybe it should be
Where InStr(1,[RawData],Chr$(13)) > 0
<snip> That's a very strange filter. It appears you are only looking for records where RawData is equal to the position where a Chr(13) exists.
Maybe it should be Where InStr(1,[RawData],Chr$(13)) > 0
Yes, I really blew it, Salad. 'preciate the working filter. This has
all come about from my desire to modify code that FredG was
clever enough to create last month. I'm trying to modify it and
a query field that calls it - effectively making the query an
ACTION query which will find and STRIP the hard returns
from a text (or memo) field. Here's the code + query field FredG
gave me...
Function StripReturns(St rIn As String) As String
On Error GoTo Err_Handler
Dim intX As Integer
Dim strName As String
Dim strNewName As String
Dim strY As String
strName = StrIn
For intX = 1 To Len(strName)
strY = Mid(strName, intX, 1)
If (Asc(strY) <> 13 And Asc(strY) <> 10) Then
strNewName = strNewName & strY
End If
Next intX
StripReturns = strNewName
Exit_StripRetur ns:
Exit Function
Err_Handler:
MsgBox "Error #: " & Err.Number & " " & Err.Description
Resume Exit_StripRetur ns
End Function
============
Call it from a query:
NewColumn:IIf(N ot IsNull([FieldName]),StripReturns([FieldName]),"")
MLH <CR**@NorthStat e.net> wrote in
news:20******** *************** *********@4ax.c om: strName = StrIn For intX = 1 To Len(strName) strY = Mid(strName, intX, 1) If (Asc(strY) <> 13 And Asc(strY) <> 10) Then strNewName = strNewName & strY End If Next intX StripReturns = strNewName
This is just ridiculously complex code.
There's a VBA constant, vbCrLf, that you can use for this, and use
Instr to find the location of that 2-character string:
Dim lngPosition As Long
Do Until InStr(strTemp, vbCrLf) = 0
lngPosition = InStr(strTemp, vbCrLf)
If lngPosition = 0 Then
Exit Do
Else
strTemp = Mid(strTemp, 1, lngPosition - 1)
strTemp = strTemp & Mid(strTemp, lngPosition+2)
End If
Loop
What you're doing there is finding where the CrLf is located and
getting the string before it and concatenating it with the string
after it.
This is actually the basic framework for a generic Replace()
function and you'd just replace the constant vbCrLf with a parameter
passed into your function.
(of course, all the above is air code, so it might break in some way
or the other)
--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc strName = StrIn For intX = 1 To Len(strName) strY = Mid(strName, intX, 1) If (Asc(strY) <> 13 And Asc(strY) <> 10) Then strNewName = strNewName & strY End If Next intX StripReturns = strNewName
This is just ridiculously complex code.
There's a VBA constant, vbCrLf, that you can use for this, and use Instr to find the location of that 2-character string:
Dim lngPosition As Long
Do Until InStr(strTemp, vbCrLf) = 0 lngPosition = InStr(strTemp, vbCrLf) If lngPosition = 0 Then Exit Do Else strTemp = Mid(strTemp, 1, lngPosition - 1) strTemp = strTemp & Mid(strTemp, lngPosition+2) End If Loop
I can see your point. But one's 8-lines and the other's
9-lines = not a huge difference there. I do like using
the VBA constant. Gives me the feeling Microsoft's
done some of the work for me.
MLH <CR**@NorthStat e.net> wrote in
news:qj******** *************** *********@4ax.c om: strName = StrIn For intX = 1 To Len(strName) strY = Mid(strName, intX, 1) If (Asc(strY) <> 13 And Asc(strY) <> 10) Then strNewName = strNewName & strY End If Next intX StripReturns = strNewName This is just ridiculously complex code.
There's a VBA constant, vbCrLf, that you can use for this, and use Instr to find the location of that 2-character string:
Dim lngPosition As Long
Do Until InStr(strTemp, vbCrLf) = 0 lngPosition = InStr(strTemp, vbCrLf) If lngPosition = 0 Then Exit Do Else strTemp = Mid(strTemp, 1, lngPosition - 1) strTemp = strTemp & Mid(strTemp, lngPosition+2) End If Loop
I can see your point. But one's 8-lines and the other's 9-lines = not a huge difference there. . . .
No, mine is 10 lines and yours is 12.
Mine is also faster, as it doesn't walk through the string character
by character, and has fewer calls to other functions. Mine could
also be reduced to 9 lines by combining the strTemp concatenations
into one line. Of course, yours could be reduced by two lines by
putting your If statement on one line.
. . . I do like using the VBA constant. Gives me the feeling Microsoft's done some of the work for me.
That's what the constants are for.
My point is that you don't need to walk through the string character
by character, which is what I considered "convoluted " when you are
dealing with replacing a 2-character string.
And, of course, becasue of that, yours is not generalizable to
replacing any string of any length, precisely because it's assuming
two characters.
Mine also assumes 2 characters, but that can be fixed with this
change:
strTemp = strTemp & Mid(strTemp, lngPosition+Len (vbCrLf))
so that you'd replace vbCrLf with the variable you're passing in as
your search string.
Yours really can't be altered to fix that without major
re-engineering.
--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
David W. Fenton wrote: MLH <CR**@NorthStat e.net> wrote in news:qj******** *************** *********@4ax.c om:
strName = StrIn For intX = 1 To Len(strName) strY = Mid(strName, intX, 1) If (Asc(strY) <> 13 And Asc(strY) <> 10) Then strNewName = strNewName & strY End If Next intX StripReturn s = strNewName
This is just ridiculously complex code.
There's a VBA constant, vbCrLf, that you can use for this, and use Instr to find the location of that 2-character string:
Dim lngPosition As Long
Do Until InStr(strTemp, vbCrLf) = 0 lngPosition = InStr(strTemp, vbCrLf) If lngPosition = 0 Then Exit Do Else strTemp = Mid(strTemp, 1, lngPosition - 1) strTemp = strTemp & Mid(strTemp, lngPosition+2) End If Loop
I can see your point. But one's 8-lines and the other's 9-lines = not a huge difference there. . . .
No, mine is 10 lines and yours is 12.
Mine is also faster, as it doesn't walk through the string character by character, and has fewer calls to other functions. Mine could also be reduced to 9 lines by combining the strTemp concatenations into one line. Of course, yours could be reduced by two lines by putting your If statement on one line.
. . . I do like using the VBA constant. Gives me the feeling Microsoft's done some of the work for me.
That's what the constants are for.
My point is that you don't need to walk through the string character by character, which is what I considered "convoluted " when you are dealing with replacing a 2-character string.
And, of course, becasue of that, yours is not generalizable to replacing any string of any length, precisely because it's assuming two characters.
Mine also assumes 2 characters, but that can be fixed with this change:
strTemp = strTemp & Mid(strTemp, lngPosition+Len (vbCrLf))
so that you'd replace vbCrLf with the variable you're passing in as your search string.
Yours really can't be altered to fix that without major re-engineering.
David. I find your points valid. Sometimes, when programming, the
developer follows a code and style they are working with and familiar
with. Because of that structure, they code differently that you do. As
far as I am concered, that's the magnificance of the mind. One person
could do something one way, another could return the same results using
a completely different method.
If I could go back to my application and rewrite it, it would be far
more effecient and "elegant" than the code that exists. But I need to
do things, inherited an app that had requirement now, and so now it is a
real fine app but there are some things about it that could be done
better.
If I had a team to look over code, then things can be done more
efficiently. Or I could test a couple of different methods to perform
something and see if one thing beats the by a milisecond, but I don't
have the time.
I need to use an example. I would use more "withs" in my code
structure...if I had the time to remember "with". I'm used to my style,
others to their's, and the way I look at it, if it works that's better
than something that doesn't work.
Do keep with the suggestions on methods to do things better. I simply
think you could do it with a less abrasive style. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: shumaker |
last post by:
I'm wondering how/why this query works. Trying to get my head wrapped
around SQL. Basically the Query deletes from the Import table all
records that are already in FooStrings so that when I do an insert from
the FooStringsImport table into the FooStrings table, then I won't get
primary key violations.
DELETE FROM FooStringsImport
WHERE EXISTS
(SELECT * FROM FooStrings
WHERE FooStringsImport.FooKey = FooStrings.FooKey)
|
by: Tom Mitchell |
last post by:
All:
I'm stumped on a query. How do I find duplicates in a table where one
of the duplicates has values is a certain field and the other doesn't.
For example, I have the following table:
tblItems
ItemID
ItemLabel
|
by: misscrf |
last post by:
I have this normalized database, and I don't understand why setting up
the forms is so hard for me. I have the main candidate entry form.
This is to enter in candidates who apply for a job. I have a tab
control with a page that shows if the candidate type is 1 of a few
types ( in code). Otherwise 2 pages show. 1 is for contact
information. This has an address subform and a phone subform. I can't
figure out how to show all address,...
|
by: Mong |
last post by:
Hi,
I've got an application that imports records from a text file into a
temporary table. I then want to insert from the temp table into a
master table but only records which are not in there already. The data
has no unique fields so to find a duplicate record each field in the
tables would need to be compared. There are 33 fields in the master
table consisting of text, number and date/time. The temp table has the
same fields except...
|
by: shank |
last post by:
I'm trying to use online samples for submitting multiple records from ASP
into a stored procedure. Failing! Through the below form, a user could be
submitting many records at a time. I'm not getting any records inserted. For
troubleshooting, I cut the form down to 1 textbox and when submitted it
populated 5 rows of the same data. So I know I'm connected, but not getting
the LOOP and NEXT correct? How do I set this up so many records can be...
| |
by: Lyle Fairfield |
last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp
The Joy of Interoperability
Sometimes a revolution in programming forces you to abandon all that's
come before. To take an extreme example, suppose you have been writing
Visual Basic applications for years now. If you're like many
developers, you will have built up a substantial inventory of code in
that time. And if you've been following...
|
by: jasmith |
last post by:
How will Access fair in a year? Two years? .... The new version of
Access seems to service non programmers as a wizard interface to
quickly create databases via a fancy wizard. Furthermore, why would
you even continue to use Access as a backend when you have a much
superior option in SQL express?
What about as a future front-end development tool? Let's get serious.
Microsoft continues to publish numerous articles and videos on how you...
|
by: Dmitry Bond. |
last post by:
Hello.
Our product works fine on all 7.x and 8.x DB2 versions. But stops to
work on DB2 v9.1.
The main problem is - duplicate primary key (sqlcode=-803) happens when
inserting records in QUEUE table.
The primary key of QUEUE table is - 3 fields - QID CHAR(4), PRI INT
and QTIME TIMESTAMP.
When inserting records into QTIME table we are using the "CURRENT
|
by: Nelson |
last post by:
Hi All,
I want to look at what happens to stock prices after a certain number
of consecutive up or down days. Let's say, for instance, I'd like to
see where a stock's price is 5 days after a run of 5 consecutive up
days.
I can't even begin to figure out the queries needed to accomplish
this. Maybe somebody can help me.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |