Minggu, 23 Oktober 2011

[MS_AccessPros] Re: Strange result of query

 

Hi Lee,

If you have not found/fixed the problem then you
could try using this Query:

SELECT [tblEmployee]![EmployeeID] Like '009*' AS 009_Match, tblEmployee.EmployeeID, Str2Hex([EmployeeID]) AS Hex
FROM tblEmployee;
It will display the EmployeeID as a hex string so
you can see what it really contains.

You will also need this function:

Public Function Str2Hex(pstr As String) As String
' Convert a string to HEX values separated by a "."
' e.g. str2Hex("ABC") returns "41.42.43"
On Error GoTo MyErr
Dim i As Integer
Dim strA As String
For i = 1 To Len(pstr)
strA = strA & "." & Right$("0" & Hex(Asc(Mid(pstr, i, 1))), 2)
Next
Str2Hex = Mid$(strA, 2)
End Function

Regards, Clive.

--- In MS_Access_Professionals@yahoogroups.com, "Lee" <leevt99@...> wrote:
>
> Hi,
> I have a text field for Employee ID that is all numeric about 85% of the time. I wrote a query to give me all of the IDs that start with a specific number sequence:
>
> SELECT * FROM tblEmployee WHERE EmployeeID LIKE '009*'
>
> and got no results. I KNOW there are employees that start like that because everyone working in a certain business unit starts with that code.
>
> So I changed it to:
> SELECT * FROM tblEmployee WHERE EmployeeID LIKE '*009*'
>
> (notice I surrounded the string with *)
>
> And got the results I wanted. Every Employee ID has 009 as the left 3 characters if they are in a specific BU, so why didn't the first one return any results? The field is formatted as text on the table. I trimmed the field and tried the original again but to no avail.
>
> Thanks
> -Lee
>

__._,_.___
Recent Activity:
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar