Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why the left(string,1) function could not be used?? 1

Status
Not open for further replies.

Koaz

Programmer
Nov 26, 2002
15
SG
Function BlnIsValidIC (ByVal strInput)
If Len(strInput) <> 9 Then
BlnIsValidIC = False
Else
If IsNumeric(Right(strInput, 1)) = True Or IsNumeric(Left(strInput, 1)) = True Or IsNumeric(Mid(strInput,2,7))
end if
End Function
-----------------------------------------------------------

This the coding which i wrote, but the Left(), right() and mid() function would return error. VBA's package is missing..

Pls advise me?? Thank
 
You second If statement doesn't appear to have a Then statement.

Hope this helps.
 
Function BlnIsValidIC (ByVal strInput)
If Len(strInput) <> 9 Then
BlnIsValidIC = False
Else
If IsNumeric(Right(strInput, 1)) = True Or IsNumeric(Left(strInput, 1)) = True Or IsNumeric(Mid(strInput,2,7)) = False Then
BlnIsValidIC = False
End if
end function
--------------------------------------------------

Not the 'then fault... the fault lied on left, right and mid. I'm actually doing a validation on the input by user.
e,g input must be in the format of 9 char, 1st one letter and 2nd - 7th numeric and end with char >> S1234567A.

rgds
 
Hi

Check for missing references (in design view of code module, choose Tools\References from menu, look for any which say missing

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi, Koaz,

If KenReay's suggestion doesn't fix your problem, give this a try:
Code:
If Len(strInput) <> 9 _
Or IsNumeric(Left(strInput, 1)) _
Or IsNumeric(Right(strInput, 1)) _
Or Not IsNumeric(Mid(strInput, 2, 7)) Then
    BlnIsValidIC = False
    Else
        BlnIsValidIC = True
End If
HTH,

Ken S.
 
Why not simply this ?
BlnIsValidIC = (strInput Like "[A-Z]#######[A-Z]")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank dude!!, I actually tried the coding on my sis's pc and it works.. I'm not pretty sure if lies problem on my pc's office 2003 which says I have a missing reference.

P.S very confidental that none of our coding was wrong. It just can't work in my office 2003 and advise one this? Or anyone had encounter the same problem b4?
 
Ideas:

- Go to officeupdate.microsoft.com and hook yourself up (be aware that some security updates break automation because of security popups).
- Repair Office installation.
- Remove references from project, shut down and open project again, re-add references.
- Create a new database and import everything. Set your references properly.
- Uninstall and reinstall office or just Access.
- Compare dll versions between a nonworking system and a working system.
- Get the latest version of various updates like MDAC and so on.
 
Once again, PHV, your code is the better. Have a star.

Ken S.
 
Thanks dude.. I would try it out.. Gosh me, I actuallly spent 3 nite in the library searching the ans, thought something wrong with my coding. ohhh.. I try to create a new database then.. and import the necessary.
 
Hi

PHV's code is neater and more understandable, so why not use it

but in the longer term you may need to use Left() etc
so:

"I'm not pretty sure if lies problem on my pc's office 2003 which says I have a missing reference."

so fix the missing reference(s) as described in earlier post using tools\references option.

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
replace LEFT, RIGHT, MID, etc with VBA.LEFT, VBA.RIGHT, VBA.MID,etc
 
Thanks folk. I managed to solve the problem by reinstalling the software. Thanks n Rgds.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top