|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I have written function in .bas module in MS Access to get the alphanumeric strings from my table Function Public Function Alphanumeric1(textstring As String) As Boolean Dim n As Integer, numFlg As Boolean, txtFlg As Boolean Dim nChr As String, nAsc As Integer For n = 1 To Len(textstring) nChr = Mid(textstring, n, 1) nAsc = Asc(UCase(nChr)) If IsNumeric(nChr) Then numFlg = True ElseIf nAsc > 64 And nAsc < 91 Or nAsc > 97 And nAsc < 122 Then txtFlg = True Else txtFlg = False Exit For End If Next Alphanumeric1 = numFlg And txtFlg End Function __________________________________________________ ________________________ Table in the database on which I am running the query tblData DataUniqueId SourceCode PromoCode 1 abcd1 123 2 dfer$% 445 3 sff%3s 345 4 xyz 347 __________________________________________________ _________________________ When I call this function from the query which is run from Query window in MS Access, it work properly Query: Select * from tblData where Alphanumeric1(SourceCode) <>0 __________________________________________________ _________________________ But when I call this query from Visual Basic code using ADO objects, it gives me an error like "Undefind function 'Alphanumeric1' ..." __________________________________________________ __________________________ Could anybody help me in resolving this error? |
|
#2
|
|||
|
|||
|
Basically you can't call user functions in Access from outside Access using ADO.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
Quote:
Thanks Doug! Is it that you can' call them by any other means? Or just using ADO, it is not possible? Could you please clarify? |
|
#4
|
|||
|
|||
|
Just put your function in an Access Module
S-
__________________
If you have found a particular post helpful, show your appreciation by adding reputation points to that user by clicking the "scales" image in the upper right had corner of their post. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Calling Function defined in MS Access (.bas module) from VB code |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|