Iterating Through A String In Access -- Please Help

Jan 20, 2005

I have a string coming in from a text field that I am inserting into an SQL Query that I want to parse for
invalid SQL characters and adjust the string accordingly.

For example:
"Foo's Bar" should become "Foo's Bar"
"C:Blah" should become "C:\Blah"

This seems like it should be simple (at least it is in other languages ::grumble:, but I can't get it to
work in Access VB.

Here's my code:
Code:Function strSqlFormat(myStr)Dim Count As Integer For Count = 0 To Len(myStr)Dim myChar As StringmyChar = Mid(myStr, Count, 1)If myChar = "'" Or myChar = "" ThenDim newStr As Integer newStr = Mid(myStr, 0, Count + 1)newStr = newStr & ""newStr = newStr & Mid(myStr, Count + 1) myStr = newStrCount = Count + 1 End IfNext Count End Function

I get an error message at the line: "myChar = Mid(myStr, Count, 1)" saying "Invalid Procedure Call or
Argument". I've tried fixes like CStr(myStr) and CLng(Count) to make sure the parameters are the right
data types, but it still gave me the same error.

Can anyone figure this out? I'm a VB newbie but I'm experienced in Java, C++, C#, etc.

View Replies


ADVERTISEMENT

Not Iterating Thru Recordset Entirely

Jan 9, 2006

Hello,

I need to find out why this code isn't going through every record, only some:

Code: 'Check the Analyte to remove Chemical Symbols from end ' - Preserve in additional field Dim strSymbol As String Dim strRemove As String Dim intLABCHECK As Integer Set dbs = CurrentDb Set rec = dbs.OpenRecordset("tblWater_Sample_Temp_Maxxam", dbOpenDynaset) 'If RS.EOF then we're at the end of the recordset already, i.e. no records If rec.EOF Then rec.Close Set rec = Nothing Set dbs = Nothing Else rec.Requery rec.MoveFirst While Not rec.EOF strSymbol = GetSymbol(rec("Analyte")) strRemove = RemoveSymbol(rec("Analyte")) intLABCHECK = StrComp(strSymbol, "(LAB)") ' if it does not equal (LAB) If (Len(strSymbol) < 6) And (Len(strSymbol) > 1) And (intLABCHECK < 0) Then rec.Edit rec("AnalyteSymbol") = strSymbol rec("Analyte") = strRemove rec.Update End If rec.MoveNext Wend End If

GetSymbol:
Code:Function GetSymbol(var As String) intPoint = CInt(InStrRev(var, "(")) If intPoint = 0 Then GetSymbol = "" Else strLastPart = Mid(var, intPoint) GetSymbol = strLastPart End IfEnd Function

RemoveSymbol:
Code:Function RemoveSymbol(var As String) intPoint = CInt(InStrRev(var, "(")) If intPoint = 0 Then RemoveSymbol = var Else strLastPart = Mid(var, 1, (intPoint - 1)) RemoveSymbol = strLastPart End IfEnd Function

View 2 Replies View Related

Print String By Access

Oct 10, 2005

I have string

I want to print the string and no by report

for example:

dim s as string

s = "hi" & vbcrlf & vbcrlf
s = s & "my name is sharon"


now I want to print the string in the printer
with default font and default size.

is it possible?

thanks!

View 6 Replies View Related

ACCESS CLOSING STRING. Help!

Feb 21, 2007

where do I add a closing string into this code and what do I write? The server said the database is not closing the access database correctly and i don't know what is wrong.

<configuration>

<appSettings>
<add key="connString" value="~/protected/pedalcardb.mdb" />
</appSettings>

<system.web>

<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to enable ASPX debugging. Otherwise, setting this value to
false will improve runtime performance of this application.
Set compilation debug="true" to insert debugging symbols (.pdb information)
into the compiled page. Because this creates a larger file that executes
more slowly, you should set this value to true only when debugging and to
false at all other times. For more information, refer to the documentation about
debugging ASP.NET files.
-->
<compilation
defaultLanguage="c#"
debug="true"
/>

<!-- CUSTOM ERROR MESSAGES
Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
Add <error> tags for each of the errors you want to handle.

"On" Always display custom (friendly) messages.
"Off" Always display detailed ASP.NET error information.
"RemoteOnly" Display custom (friendly) messages only to users not running
on the local Web server. This setting is recommended for security purposes, so
that you do not display application detail information to remote clients.
-->
<customErrors defaultRedirect="error.htm" mode="RemoteOnly" />

<!-- AUTHENTICATION
This section sets the authentication policies of the application. Possible modes are "Windows",
"Forms", "Passport" and "None"

"None" No authentication is performed.
"Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to
its settings for the application. Anonymous access must be disabled in IIS.
"Forms" You provide a custom form (Web page) for users to enter their credentials, and then
you authenticate them in your application. A user credential token is stored in a cookie.
"Passport" Authentication is performed via a centralized authentication service provided
by Microsoft that offers a single logon and core profile services for member sites.
-->
<authentication mode="Forms" />

<!-- AUTHORIZATION
This section sets the authorization policies of the application. You can allow or deny access
to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
(unauthenticated) users.
-->

<authorization>
<allow users="*" /> <!-- Allow all users -->
<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>

<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every page within an application.
Set trace enabled="true" to enable application trace logging. If pageOutput="true", the
trace information will be displayed at the bottom of each page. Otherwise, you can view the
application trace log by browsing the "trace.axd" page from your web application
root.
-->
<trace
enabled="true"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="true"
/>

<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong to a particular session.
If cookies are not available, a session can be tracked by adding a session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>

<!-- GLOBALIZATION
This section sets the globalization settings of the application.
-->
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>

</system.web>

</configuration>

View 1 Replies View Related

Modules & VBA :: Separate Numbers And String From Alpha-numeric String

Jun 7, 2013

MS-Access VBA code to separate numbers and string from an alphanumeric string.

Example:

Source: 598790abcdef2T
Output Required: 598790

Source: 5789065432abcdefghijklT
Output Required: 5789065432

View 13 Replies View Related

String To Access With Delimiter Pipes

Nov 26, 2007

I have the a while loop with gives the string as following

1|2|Joe|Mark

2|4|Mike|Smith

….




I successfully created the .mdb with the tables. But how do I insert the above string with delimiter as pipes?


Any Suggestions…


Thanks

View 2 Replies View Related

Specifying Connection String In MS Access Forms

May 9, 2013

I have a question about connection strings. Basically I have an access front end and an access back end. It works fine for now, but when it gets rolled out, I don't want to have to manually relink the tables every time. Is it possible to hard-code the database connection strings for all the tables used in the solution as the paths won't change once deployed?

View 4 Replies View Related

General :: Which Function In Access Return Last Value In A String

Aug 14, 2013

Which function in access return the the last value in a string.

Period 1 Period 2 Period 3
10 20 30

I need the function to return 30.The reason behind this I have different periods for categories and my formula I'm using needs the ending value.

View 1 Replies View Related

General :: Specifying Connection String In MS Access Forms

May 9, 2013

I have a question about connection strings. Basically I have an access front end and an access back end. It works fine for now, but when it gets rolled out, I don't want to have to manually relink the tables every time. Is it possible to hard-code the database connection strings for all the tables used in the solution as the paths won't change once deployed?

View 9 Replies View Related

Search Through All Access Queries For Text In SQL String

Feb 2, 2012

I need to find a way to search through all of the queries in my Access 2007 database to change the names of more than a few variables. There are close to 900 queries I need to search through many of which may use the variables as criteria, so if I miss even 1 instance I might screw myself completely.

I found this post and it tells me exactly what I need to do. Only problem is the post was written in 2002, and I've followed the below instructions only to have it not work.

As a contractor working predominantly on databases I haven't developed, it can be a daunting task trying to find references to tables, fields or functions within a list of several hundred queries.

The following code is attached to a command button on a simple form listing all queries in the database. The record source for the form is

SELECT DateCreate, Name FROM MSysobjects WHERE Type=5 ORDER BY DateCreate DESC

There is a text box where the user enters the text to search for. The code builds a table containing the SQL string of every query, then searches for the required text, and displays those that match.

Your form also needs a procedure the set the record source back to the default.

There are off-the-shelf applications such as Speed Ferret which perform this sort of function, however some employers are too cheap to purchase them!

Code:
sub cmdFilter_Click()
Dim db As Database
Dim rs As Recordset
Dim rsFilter As Recordset
Dim tdf As TableDef
Dim strSQL As String
Dim strQdf As String

On Error GoTo ErrorHandler

[Code] ....

View 11 Replies View Related

Modules & VBA :: MS Access 2010 String Records Of Two Tables

Feb 14, 2014

I have two tables linked via Project ID as shown in the attached file. I need Module to concatenate Project sub types against Project Types.

View 3 Replies View Related

Modules & VBA :: How To Prevent Access Change String To Date

Dec 23, 2014

I wrote a VBA code to get the field value of a csv file, then use it to update the database table. I paste some of my code below

Dim objConn As New ADODB.Connection
Dim objRs As New ADODB.Recordset
Dim objUpdate As ADODB.Connection

objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & theFolderName & ";Extended Properties='text;HDR=Yes;FMT=Delimited'"

[Code] ....

1. The target of this code is to set the [Section] value in the table
2. The [Section] value is at the 3rd column inside the csv file
3. By using the UPDATE query, it map the [Section] value to the corresponding [Program] and [Course] in the table

This code did the job. But the problem is the string of the [Section] value is like "2-22-01". But after update to the table, the value become "2/22/2001".

The value is a string text, not date. How can I prevent this happen ?

I just attached 2 files, 1 mdb and 1 txt (change the extension to csv before test).

View 3 Replies View Related

String Validation (string Must Start With Http://)

Mar 12, 2007

Hi all,

I was looking for some help. I am trying to setup a table with a field for web address. People are entering www.website.com etc however I need them to make sure it starts with http:// Is their any way I can put validation on the field to make sure that this is entered? Or maybe I could use an input mask?

Any suggestions would be gratefully recieved.

Andy.

View 3 Replies View Related

Queries :: Convert String Back To Hyperlink In Access Query From SQL Table?

Nov 10, 2014

I am in the process of building a new database in SQL to replace my MS Access database. However, I will continue to use the Access forms, queries, and reports. The new tables will house much of the same data. In multiple tables I have hyperlinks that were created and added in the original Access tables. To import these hyperlinks into the new SQL tables I have converted them to 'Long Text' before exporting, thus changing them into strings.

For example:

Hyperlink - Email - Add Additional Mailbox to Outlook (2010) has been changed to:

Email - Add Additional Mailbox to Outlook (2010)#ServernameServerfolderDocumentationRea dy to GoOutlook TemplatesEmail - Add Additional Mailbox to Outlook (2010).oft#

The obvious issue that I am running into is that after the SQL database table has been linked to the Access database it still displays the entire string when I open the table. The form has a textbox and search button that is used as a search function. This runs a query that returns all "search results" for the desired information. Is there a way that the query can convert the string back into a hyperlink so that the query displays just Email - Add Additional Mailbox to Outlook (2010) as a hyperlink and not the entire string?

View 1 Replies View Related

Search For A String Within A String

Oct 27, 2006

I have a column called CPU_S within a table called workstation that contains sample text like P111 933

I want to use the update command to search the CPU_S column for entries that contain this in there string then add P3 to a column called CPU_N

So far I have the code below but I don't know how to search a column entry for a specific string within a string. Can this be done and how?


UPDATE workstations SET CPU_N = "P4"
WHERE CPU_S = ;

View 3 Replies View Related

String Not Getting Any Value

Jun 8, 2005

It worked in acces 2000, and now am using acces 2003. Anybody any clue why the string strVoorstel would not get the value? It just returns nothing.

Here's the code:

Dim strVoorstel As String
Dim lngTel As Long
Dim strQer As String
Dim strDa As String
Dim lngNum As Long

...........

View 6 Replies View Related

SQL String

Jul 26, 2006

Hi Folks,

i am using the sql below but i am having a little syntax error:

i am trying to refer to a variable called strRAGCol


strSQL = "SELECT tblSite.SiteID, tblSite.SiteRAG, tblSite.Active " _
& " FROM tblSite " _
& " WHERE (((tblSite.Active)=Yes)AND((tblSite.SiteRAG)= strRAGCol));"

Any help much appreciated.

Mark

View 4 Replies View Related

SQL String Help Please

Sep 29, 2005

The following SQL query is returning no records when I know for a fact there are some there! Can anyone please hlp me?!

Dim strSQL As String
strSQL = "SELECT * FROM tblHirer WHERE HirerSurname= 'Forms!frmFinanceProposal!Child845!Text430'"
rsFindDuplicates.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rsFindDuplicates.RecordCount


Also, I was wondering how I would put as 2nd filter on the recordset to equal a particular date?

Cheers

View 2 Replies View Related

Sql String

Dec 16, 2004

I had a query and the sql is:

SELECT Institutions.*, Institutions.merge, Institutions.Inst_type
FROM Institutions
WHERE (((Institutions.merge)=True) AND ((Institutions.Inst_type)=[forms]![merge_inst_type]![Inst_type]));

and I had a command button which process

MergeAllWord ("select * from merge_query_true")

but I am getting an error like this "make sure the sql is correct , sql was
select * from merge_query_true

select * from merge_query_true ---- is this code ok?

If I had cut the part "AND ((Institutions.Inst_type)=[forms]![merge_inst_type]![Inst_type])); from the sql it works fine....

View 4 Replies View Related

SQL String

May 30, 2007

WHat am I doing wrong...I cannot get the syntax correct...

Form the Query Builder:

SELECT tbl_GroupMembers.GroupNumber, tbl_GroupMembers.Email
FROM tbl_GroupMembers
WHERE (((tbl_GroupMembers.GroupNumber)="10"));


NEED IT TO BE IN THIS SQL STATEMENT:

Set rs = dbs.OpenRecordset("Select * From tbl_Groups", dbOpenDynaset)

View 3 Replies View Related

String Length.

Aug 19, 2005

I have a fax number field iwhich has a mask. +(000)-00-000-000 in a table of many records.
The problem is that every record has a number in the first part of country code +(001)which must have come there by mistakes, few records have complete and true fax numbers.

I need a query that can Update this Fax_Number field where the length of the string is less than 7 digits.
Some thing like UPDATE Contacts SET Contacts.Fax_Number = ""
WHERE ((Len("Fax_Number")>"6"));

How can i do this. Thanks.

View 4 Replies View Related

How To Split Up This String

Sep 15, 2005

I have a string:

Cars > Car Import > Car Import: Car Import

The first section is the Category, the second is the Product, the third is the SubProduct and the fourth is the keyword.

What is the best way to split each of these words into its own variable? I think I can do the first and end one but not the Car Import and Car Import one.

Thanks,

Dave

View 4 Replies View Related

Lookup String

Sep 18, 2005

I have a 67 binary code string produced from a query which concatenates these 1's and 0's.

What I need to do is have access decide what a particular string value/range is and return the process name. e.g

11000000000000000000000000000000000001000010000000 00000000000000001. The process name would be COMP RESOLVED MSA


10100000000000000000000000000000000001000010000000 00000000000000001.The process name would be COMP UNRESOLVED MSA

00000000000000000111010000000110000000000000000000 00000000000000001

The process name would be MSA NEW

There could be about 60 different Process Names

View 1 Replies View Related

Please Look At This Boolean Vs String

Dec 2, 2005

I'm working on a software that was developed by someone who left the company. The problem is that the software works for all locations execpt one that is in austria, after debuging I found out that there is a statement in the code that uses boolean true or false, the only way it worked is when I put an if statement with false or true as string, ex: if doc = "true" then
buttom line has anyone faced this problem, I searched microsoft website and they said that some vb engines don't convert boolean to string. Please Please if someone has a clue try to help. Thanks.

View 4 Replies View Related

Need Help With String Formatting

Dec 15, 2005

Hey everyone, I need some help with formatting a string for use with the DoCmd.RunSQL() method. I can't figure out how the hell VB deals with escape characters for the purpse of variables inside strings. I have this line right now.

strSQL = "INSERT INTO OS (OS) VALUES(" + OS.Value + ")"


This is supposed to insert one row into the "OS" Table, in the "OS" field. In my form there is a textbox called "OS" and I'm trying to insert that value into the DB table.

Two things.
1) Yes, I know, I have a lot of things named "OS"
2) Yes, I know I don't need to use a string here, but I'm just presenting this is an abbreviated example, in my full program I do in fact need a string.

View 3 Replies View Related

String In Textbox

May 2, 2006

Hi,

I have string SELECT Field from Table:

A1
A2
A3
....

I need to see records in textbox: A1, A2, A3..

Thank You in Advance

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved