Modules & VBA :: Cut Off First 6 And Last 2 Characters Of String

Mar 24, 2014

I would like to cut off the first 6 and last 2 Charaters in an after update event but not sure how, I cannot use mid as the length of the string may change but never the first 6 or last 2, can some one show me how it's done ...

View Replies


ADVERTISEMENT

Modules & VBA :: Check If String Contains Numeric Characters?

Nov 7, 2013

Is there an easy way in VBA to loop through a recordset and determine if the text string in a text field includes numeric characters?

I'm trying to do something like this:

Code:
Do Until rst.EOF
rst.Edit
If Left(rst!FldText,10) contains any numeric characters Then
rst!FldType = "Mixed"
ElseIF Left(rst!FldText,10) contains "PO" Then
rst!FldType = "PO"
Else
rst!FldType = "Std"
End If
rst.Update

View 2 Replies View Related

Strip Last 21 Characters From A String

Sep 21, 2005

I need to be able to strip the last 21 characters from the following strings using a command in a query. Any ideas? I know I need to Instr command but not sure how to do it.

Greg
Impulse Manufacturng

96803-386868-386869-163241
INSP-F96191B-384761-389552-162206
INSP-F96191A-384758-389551-162205
F96191A-384758-389551-162205
F96191B-384761-389552-162206
INSP-97407-389462-389463-164428

View 5 Replies View Related

Want To Know How To Chop The Last 3 Characters Of A String

Nov 24, 2005

I am new to VB and want to know how to chop the last three characters off a string. Am writing dynamic SQL and have to take the AND off the last WHERE clause if needed.

Any help greatly appreciated

View 5 Replies View Related

Removing Characters From A String

Jan 5, 2005

is there a way to do this in VBA in Access I looked at trim but it does not help much

Dim MyString, TrimString
MyString = " <-Trim-> " ' Initialize string.
TrimString = LTrim(MyString) ' TrimString = "<-Trim-> ".
TrimString = RTrim(MyString) ' TrimString = " <-Trim->".
TrimString = LTrim(RTrim(MyString)) ' TrimString = "<-Trim->".
' Using the Trim function alone achieves the same result.
TrimString = Trim(MyString) ' TrimString = "<-Trim->".

I have a select statment setting the data that will be in a combo box
I would like to trim this data...

for example the select statment returns something like
category>subcatgory>field>subfield

so I want to trim it down to be
field>subfield

View 3 Replies View Related

Trimming Off First 7 Characters In A String

Oct 21, 2005

My DB is on SQL Server with an Access adp front end.

SQL uses the Windows NT user name and password for security and also pulls in the user name into a field in every record so we know who has added and modified it.

For one table we are actually using the user name field on the form and in a report for reasons other than security.

The user name is filled in with first the name of the network group, then a slash, then the user name itself. So there are 7 characters I don't really care about.

Is there a way in VBA to remove those first seven characters and only show what comes afterwards? Thanks for the help!

View 3 Replies View Related

Characters Before Searched String?

Dec 9, 2011

Is there a function, similar to mid, except that it will return all characters prior to the searched string instead of after?

View 4 Replies View Related

Parsing The Left And Right Characters Of A String

Aug 19, 2005

I have the following string: NE1220904
I need to remove the left two characters and the right four characters of a string in a query. I have found how to remove one side or the other, but not from both sides. Thanks in advance for the help!

View 6 Replies View Related

Left Three Characters From String Using Query

Sep 8, 2005

In MySQL I can use the LEFT(3, field_name) command, but I essentially want access to pull all records from a table where the the first three digits of a number field match those pre-selected by a form drop down.

This database is in Access 97. Is there a way to compare the first x number of digits using SQL only, or do I need to run each line through code first, and then check it (I really don't want to do that)?


example numbe rin field:

123456789

SQL checks to see if 123 matches value selected on a form.

View 1 Replies View Related

Queries :: Replace 2 Characters In String With 0s

Dec 8, 2014

I'm familiar with writing a replace query to replace characters or strings but what I'm trying to do this time is a bit unique to me. I have a string of numbers that will either be 8 or 9 digits in length. The first 1 or 2 digits will be the State code (1-50 hence the discrepancy in number of total digits), then a 2 digit agency code, then the last 5 digits are a producer code. What I need to do is change the 2 digits for the agency part both to 0. So basically characters 6 and 7 if you're counting from the right. To me it feels like I'm trying to do it backwards so I'm having a hard time writing it.

View 12 Replies View Related

Strip A Filename String Of Any Disallowed Characters

May 8, 2006

I am writing some search results to an excelsheet for reports using the time and date functions to build a filename. I downloaded a StripSpecialCharacters() module, but it doesn't take them all out (only takes ascii above 127).

Does anybody know of another function to do it. searched the archive to no avail.

Thanks in advance

View 5 Replies View Related

Queries :: Possible To Query A Field For Special Characters In A String?

Oct 11, 2013

Is it possible to query a field for special characters in a string? I want to find any records that have characters other than A-Z, 0-9

View 9 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

Modules & VBA :: How To Replace Characters With Spaces

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

Modules & VBA :: Getting Extra Characters In Column

Aug 16, 2014

Copying a column from one record to another. Code is:

Code:
Set fld = Records.Fields("violationLocalOrdinanceNumber")
If Len(fld & "") > 0 Then
rst!LOR_NB = Nz(Records!violationLocalOrdinanceNumber, "")
Debug.Print ("LOR NB:" & rst!LOR_NB & "." & " len:" & Len(Nz(Records!violationLocalOrdinanceNumber, "")) & " len new:" & Len(rst!LOR_NB))
End If

Some of the output I'm getting is:

LOR NB:8.08(5) . len:7 len new:25
LOR NB:7.08(5)(a) . len:10 len new:25
LOR NB:7.08(5)(a) . len:10 len new:25
LOR NB:7.08(5)(A) . len:10 len new:25
LOR NB:7.08(5)(A) . len:10 len new:25
LOR NB:7.08(5)(a) . len:10 len new:25
LOR NB:8.08(5) . len:7 len new:25

No matter what the original string length is, something is adding extra spaces and forcing it to 25 in the new record. This is the only field I've been able to identify with this issue. Column definition is char(25), no indexes or anything special that I can tell.

Tried adding a left() function call after the assignment but that didn't work either.

View 4 Replies View Related

Modules & VBA :: Remove Special Characters

Feb 25, 2015

I have a Memo field that is used to be a description of a document. I don't know what the user will put in (could be anything), but it is eventually passed in a string to a query, etc.I discovered during testing that if an apostrophe is entered (Ex: This document explains how to deal with Joe's pleasant disposition.), it breaks my code. I then realized that all reserved words and characters would cause this problem.

I can get around this one just by using Replace(str, "'", "''"). However, I know there are others that will cause problems, and I don't want to end up with a string of replace statements just to fix them.

View 2 Replies View Related

Modules & VBA :: Blank Out Password Characters?

Oct 28, 2013

I am currently using

Code:
Private Sub Form_Open(Cancel As Integer)
Const cstrPassWord As String = "open"
Dim strPassWord As String
strPassWord = InputBox("Password:")
If Not strPassWord = cstrPassWord Then
Cancel = True
End If
End Sub

to password protect a form within my database. it is working great however i was wondering if there is any way to make the characters appear as **** when entering the password?

View 9 Replies View Related

Modules & VBA :: Find And Replace Special Characters

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

Modules & VBA :: Web Page Template - Adding Characters Before And After Sentence

May 6, 2014

I'm using Access to create some web page templates. To Do this I have a memo field called "Description" into which I'm entering text. Example:

This is an obvious description example

What I need to be able to do is put a "<p>" before each sentence and a "</p>" at the end of each sentence. Examle

<p>This is an obvious description example</p>

The information is stored in a form page, and the text have paragraphs.

View 1 Replies View Related

Modules & VBA :: SQL To Copy Field Contents With Reserved Characters

Jul 11, 2013

I've got some code that loops through a record and copies the non-null fields to another record. This is the partial code:

For Each fld In tdf.Fields
If Not IsNull(Forms!contact_lookup![Contact_sub subform1].Form(fld.NAME)) Then
strSql = "UPDATE tbl1 SET tbl1.[" & fld.NAME & "] = '" & Forms!contact_lookup![Contact_sub subform1].Form(fld.NAME) & "' " & _
"WHERE tbl1.[FC_APN] = '" & Me.txtApn & "';"
DoCmd.RunSQL strSql
End If
Next fld

This works fine until it encounters a field whose contents has a reserved character, like a single quote (" ' ") in it, for example, "What's the what." At that point the SQL thinks there's a " ' " missing in the statement, and I get an error 3075 (syntax error: missing operator).

View 2 Replies View Related

Modules & VBA :: Remove Special Characters From File Name (when Saving)

Feb 20, 2014

I use the below code as part of a database which creates documents and then saves them using data from the form fields.

Every now and again one of the form fields contains a "special" character such as /,@,& and this prevents the file from saving.

Is there a simple addition to the below code to remove special characters from the file name if there is one present?

It causes all sorts of issues as many people don't realise that there has been a problem until it is too late.

Code:
objWord.ActiveDocument.SaveAs2 FileName:="C:UsersPublic" & Forms![Front Page]![Site 2 Name] _
& " " & Forms![Front Page]![Combo79] & " " & "O2" & ".doc"
objWord.ActiveDocument.Close

View 9 Replies View Related

Modules & VBA :: Limit A Field To Only Alpha Numeric Characters

Sep 25, 2013

I would like to know how to limit a field on a form to only Alpha Numeric characters.

Example: ~AAUZNTO

This would be scanned by a bar code and I want the field to show only this when scanned: AAUZNTO

View 14 Replies View Related

Modules & VBA :: Preserving Characters From Excel Import To Access

Feb 26, 2015

The excel worksheet that I am importing into my database has some formula's, for an example =2+2. I am importing this worksheets, then checking fields against the main table, then exporting back to Excel. But I want to be able to keep the "=" signs when I import to remain so that when I export back into Excel the columns with the formulas will already be there.

View 2 Replies View Related

Modules & VBA :: Transfer Characters To Textbox On Button Click

Dec 9, 2013

I have a textbox with about 400 characters, I also have 5 textboxes next to it. I want to click a button and I want to transfer the characters to the other textboxes 208 characters at a time.

View 3 Replies View Related

Modules & VBA :: Asset Database - Special Characters In DLOOKUP Expression

Jul 29, 2013

I have an asset database I am designing to manage our computer inventory and assets.

I am trying to get a DLookup to work with one of my forms that will auto-populate some of the fields depending on what is entered in to the ProductID field. For instance, Make, Model, Asset type...

My problem is that the string that returns contains special characters, specifically "#" and gives me the error message -

Run-time error '3075':
Syntax error in date in query expression 'productID=EN371UA#ABA'.

My expression is definitely working, it just looks like it things it has something to do with date/time which it does not. Unfortunately, most HP equipment contains a # in the Product ID number.

Here is my expression -

Private Sub ProductIDCombo_AfterUpdate()
Make = DLookup("Make", "productlist", "productID=" & [ProductIDCombo])
End Sub

Make is the field I am looking up from the ProductList table. The Product ID is the ID I'm looking up from the ProductList table to find the make. My problem is actually getting it to return the correct value of "HP or Dell or Lenovo". etc.

View 12 Replies View Related

Modules & VBA :: Access Memo Field Copy To Excel Truncates At 255 Characters

Nov 25, 2013

Two Solutions to address moving an Access Memo field into Excel when string has > 255 characters. All my 'reports' use Excel VBA (Access Reports are not used). The Excel reports can have 40,000 records. Speed to create the report can be an issue.

Describing 2 Solutions below to address moving Access memo fields with > 255 characters into Excel.After running this code

Code:
720 ObjXL.DisplayAlerts = False
ObjXL.Columns("X:X").Select
ObjXL.Selection.NumberFormat = "@" ' set column to Text
730 ObjXL.Worksheets(intWorksheetNum).Cells(intRowPos, 1).CopyFromRecordset rsNutsAndBolts

The Comments column are limited to 255 characters. So, the CopyFromRecordset (recordsetvariable) creates the 255 character limitation.

The reason? The 255 character limit is because CopyFromRecordset sutomatically uses the Characters property of the Range object. The 255 limit would not be there if the Cell Value property is used to assign the string to that cell.

Dim sRx as String ' String Prescription
sRx = "String with > 255 characters ... you fill in the rest ...."
Cells(1, 1).Value = sRx ' Cell's Value property assignment can be very large

Solution 1:

The record set is still in memory. By using a loop, a cursor can start with record 1 (memo column) and assign that value to the Excel row / column using the .value as shown above. Basically, this moves one memo field at a time, record by record. e.g. Read First recordset in Access, copy to variable, assign value to Excel row/column Then move next on each Access and Excel.

Solution 2:

An Access Memo filed [RxNotes] can have up to 750 characters. Cut it apart into three new fields that end up out in the very right Excel columns AA, AB, AC.

Note1=Mid([RxNotes],1,250)
Note2=Mid([RxNotes],251,250)
Note3=Mid([RxNotes],501,250)
Then using Excel Object - Concat the cells back cell by cell...
X2=CONCATENATE(AA2,AB2,AC2))

Then delete the columns AA, AB, AC to hide the evidence..Neither solution is all that elequent. Read about this and by golly, it made a difference

ConcatComments = "'" & CommentString

Before using the CopyFromRecordset be sure to add a single quote in front of the large string.

Turns out the interface between Access and Excel look for this to prepare Excel immediately for the string to be a string, not something else. Some of my strings had weird print characters that kind of looked like Japenese characters. It seemed random, it always happened if the string was 255 or more characters (ramdonly, not always). The single quote doesn't show up in Excel, but got rid of all the noise.

View 5 Replies View Related







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