B
Bryan
Hi.
I've written a function to help me obtain a certain section
of a field, as separated by the tilde character '~', although
it should work for any character.
Here's the VB code for my access function:
Attribute VB_Name = "vb_library"
Option Compare Database
Option Explicit
Public Function separated_field(inString As String, _
field_no As Integer, _
separator As String) As String
Dim list As Variant
Dim tempstr As String
Dim counter As Integer
If field_no < 1 Then field_no = 1
tempstr = Trim(inString) + separator
list = Split(tempstr, separator)
If field_no > UBound(list) Then
separated_field = ""
Else
separated_field = Trim(list(field_no - 1))
End If
End Function
And here's a typical function call -
separated_field(Trim([bj_salesumm].[EXTRA1]),6,"~") = 'TRUE'
What we do to save changing structure a lot in our system is pack the data
into a large field, separated by a separator character. We chose the tilde
because
it is rare to non-existent in our natural data.
This worked in testing, but now I'm trying to add it to a real database and
I can't
get it to work. I get a "data type mismatch in criteria expression" error.
Does anyone have any idea where I'm going wrong here?
Thanks in advance!
Bryan
I've written a function to help me obtain a certain section
of a field, as separated by the tilde character '~', although
it should work for any character.
Here's the VB code for my access function:
Attribute VB_Name = "vb_library"
Option Compare Database
Option Explicit
Public Function separated_field(inString As String, _
field_no As Integer, _
separator As String) As String
Dim list As Variant
Dim tempstr As String
Dim counter As Integer
If field_no < 1 Then field_no = 1
tempstr = Trim(inString) + separator
list = Split(tempstr, separator)
If field_no > UBound(list) Then
separated_field = ""
Else
separated_field = Trim(list(field_no - 1))
End If
End Function
And here's a typical function call -
separated_field(Trim([bj_salesumm].[EXTRA1]),6,"~") = 'TRUE'
What we do to save changing structure a lot in our system is pack the data
into a large field, separated by a separator character. We chose the tilde
because
it is rare to non-existent in our natural data.
This worked in testing, but now I'm trying to add it to a real database and
I can't
get it to work. I get a "data type mismatch in criteria expression" error.
Does anyone have any idea where I'm going wrong here?
Thanks in advance!
Bryan