Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / June 2007

Tip: Looking for answers? Try searching our database.

Ignore letters, recognize numbers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gee... - 01 Jun 2007 00:23 GMT
I have model numbers with central numbers, surrounded by letters, like this:
AP9056X
RIC90
HIP80900GXS

What I need is code that will only recognize the numbers...when it fires, it
will return this:
9056
90
80900

Can anyone help me?

Thank you in advance.
Gee
fredg - 01 Jun 2007 01:23 GMT
> I have model numbers with central numbers, surrounded by letters, like this:
> AP9056X
[quoted text clipped - 11 lines]
> Thank you in advance.
> Gee

Surrounded by letters, not intermixed?

Create a User Defined function (in a module).

Function ValNumber(strString As String) As Long
On Error GoTo Err_Handler
Dim intX As Integer
Dim intY As Integer
intY = Asc(strString)
Do While intY < 48 Or intY > 57
  intX = intX + 1
     If intX = Len(strString) Then Exit Do
        intY = Asc(Mid(strString, intX, 1))
Loop
If intX = 0 Then intX = 1

ValNumber = Val(Mid(strString, intX))

Exit_ValNumber:
  Exit Function
Err_Handler:
  MsgBox "Error: " &  Err.Number & "  " & Err.Description
Resume Exit_ValNumber

End Function

You can call it from a query using:
NewColumn:ValNumber([FieldNaem])

or directrly in an unbound control on a form or report:
=ValNumber([FieldName])
Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Gee... - 01 Jun 2007 16:49 GMT
Wow...that much huh?
OK...I'll give it a try.
Thank you, very much, for such a quick response!
G

> > I have model numbers with central numbers, surrounded by letters, like this:
> > AP9056X
[quoted text clipped - 43 lines]
> or directrly in an unbound control on a form or report:
> =ValNumber([FieldName])
Gee... - 01 Jun 2007 17:10 GMT
I'm trying this, but it's not making sense to me.

I'm pretty new to this kind of complicated code so call me an idiot but can
you be more clear?

When "Command9" is clicked,  I need it to look at a field called "MOD", pull
out the numbers and put them in a field called "CD".

Thank you for your help...I'm thinking I may need some more training!

G

> Wow...that much huh?
> OK...I'll give it a try.
[quoted text clipped - 48 lines]
> > or directrly in an unbound control on a form or report:
> > =ValNumber([FieldName])
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.