String comparision in selection

Tep

Registered User.
Local time
Today, 21:31
Joined
Oct 6, 2010
Messages
37
Hello,

I have a string "buildingHierarchyCode" with values as:
Z0001
Z0001.0001
Z0001.0002
Z0002
Z0002.0001
Z0002.0002

In a first combobox (called Niveau1) I can make a selection from values with a lenght of 5 characters in buildingHierarchyCode and I have a second combobox (Niveau2) with values from buildingHierarchyCode with criteria:
1. it should have a lenght of 10 characters
2. It should start with the 5 characters which are selected in Niveau1.

For this I have a After Update event of Niveau1:

Code:
    Dim sSql As String
    sSql = "SELECT code, name, buildingHierarchyCode FROM dbo_FOODEX2 WHERE buildingHierarchyCode = " & Niveau1.Column(2) & " ORDER BY 3;"
    Niveau2.RowSource = sSql
    Niveau2.Requery

But this does not work...:(

So, how can I make a comparison of the strings buildingHierarchyCode and Niveau1.Column(2) in this selectioncriterium so that I can select only values of buildingHierarchyCode that starts with the 5 characters selected in Niveau1.Column(2) ?
(I did not try yet the criterium of a lenght of 10 characters).

Thank you in advance!
Tep
 
Howzit

Try this

Code:
sSql = "SELECT code, name, buildingHierarchyCode FROM dbo_FOODEX2 "
sSQL = sSQL & "WHERE (((dbo_FOODEX2.buildingHierarchyCode)<>'" & me.Niveau1.Column(2) & "') "
sSQL = sSQL & "AND ((Left(dbo_FOODEX2.buildingHierarchyCode,5))='" & me.Niveau1.Column(2) & "')) ORDER BY 3;"
 
Great! It works! Thank you very much Kiwiman.
 

Users who are viewing this thread

Back
Top Bottom