Passing Function values to a Query

F

FBxiii

Hi. I think this may be impossible but I will ask anyway!

I have created a function that evaluates 2 values from fields in a query.
The function passes a string back made up of 2 parts. E.g. ABCDE - 4a

The ABCDE is a matched part of the 2 values and the 4a is how they were
matched. (I wont go into too much detail but its a 'fuzzy matching' function)

Is it possible to have the function return the 2 values seperatly and
display each one in its own field? I am not sure if functions can pass
arrays back to queries and how I would get the query to use all elements of
it.

I did say I thought it would be impossible :)

Cheers,
Steve.
 
S

Stefan Hoffmann

hi Steve,
Is it possible to have the function return the 2 values seperatly and
display each one in its own field? I am not sure if functions can pass
arrays back to queries and how I would get the query to use all elements of
it.
You may use a store-and-forward system:

--
Option Compare Database
Option Explicit

Private Type TypeResult
Part As String
Method As String
<AFieldList>
End Type

Private m_Result As TypeResult

Private Sub Match(<AFieldList>)

'do magic here
'and store it in m_Result

End Sub

Public Function GetPart(<AFieldList>) As String

If m_Result.<AFieldList> <> <AFieldList> Then
Match AFieldList
End If
GetPart = m_Result.Part

End Function

Public Function GetMethod(<AFieldList>) As String

If m_Result.<AFieldList> <> <AFieldList> Then
Match AFieldList
End If
GetMethod= m_Result.Method

End Function
--

<AFieldList> denotes your two values. You need to implement the correct
data types yourself. Remember to use Variant, if your fields can be
null, otherwise it may throw errors.


mfG
--> stefan <--
 
F

FBxiii

Thanks for the reply.

You say <AFieldList> denotes my values. How do I implement them into the
code?

I am using strMSN_1 and strMSN_2 as my variables that hold the values...

Thanks,
Steve.
 
S

Stefan Hoffmann

hi Steve,
You say <AFieldList> denotes my values. How do I implement them into the
code?
I am using strMSN_1 and strMSN_2 as my variables that hold the values...

Private Type TypeResult
Part As String
Method As String
MSN1 As String
MSN2 As String
End Type

Private m_Result As TypeResult

Private Sub Match(AMSN1 As String, AMSN2 AsString)
End Sub

Public Function GetPart(AMSN1 As String, AMSN2 AsString) As String

If (m_Result.MSN1 <> AMSN1) or (m_Result.MSN2 <> AMSN2) Then
Match AMSN1, AMSN2
End If
GetPart = m_Result.Part

End Function



mfG
--> stefan <--
 
S

Stefan Hoffmann

hi Steve,
How do I get the results into the fields of my query?
Just use 'em in the query builder:

Part: GetPart([MSN1], [MSN2])

and

Method: GetMethod([MSN1], [MSN2])


mfG
--> stefan <--
 
F

FBxiii

Thanks for your help Stefan, thats working great now :)

Maybe not so impossible after all!

Cheers,
Steve.

Stefan Hoffmann said:
hi Steve,
How do I get the results into the fields of my query?
Just use 'em in the query builder:

Part: GetPart([MSN1], [MSN2])

and

Method: GetMethod([MSN1], [MSN2])


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top