al9315 said:
Hi Chris, I greatly appreciate you taking the time to reply !! BUT - you
are obviously way beyond me. I am trying to learn Access2003 on my own !?
I have managed to import all the data from Dataease where I successfully -
years ago wrote the Database - all worked !!
I am getting stuck now - not sure where to type all this Select etc ..?
Thanks again for trying to help !!!!
Al
Sample Tables:
Note: I used only two Track Fields for simplicity's sake.
Paste the following into a query in SQL View, then execute it.
CREATE TABLE UnnormalizedAlbums
(AlbumID AUTOINCREMENT
,NameAlbum TEXT(72) NOT NULL
,Track1 TEXT(72) NOT NULL
,Track2 TEXT(72) NOT NULL
)
Load the table with the following data:
NameAlbum, Track1, Track2
My Album, My Song 1, My Song 2
Your Album, Your Song 1, Bye Bye Blackbird
The Album, A Song 1, A Song 2
Their Album, Bye Bye Blackbird, Their Song 2
Paste the follwoing into a new blank Module in the Visual Basic
Editor.
Execute it by typing "? CheckMultipleColumns("Bye Bye")" in the
immediate window and pressing Enter:
Public Function CheckMultipleColumns(SearchParameter As String)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim fld As DAO.Field
Dim lngRowFound As Long
Dim strSQL As String
Dim strTrack As String
strSQL = "SELECT * FROM UnnormalizedAlbums;"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL)
lngRowFound = 0
strTrack = "Track"
rs.MoveFirst
With rs
Do Until .EOF
For Each fld In .Fields
If Left(fld.Name, 5) = strTrack Then
If fld.Value Like "*" & SearchParameter & "*" Then
lngRowFound = .Fields("AlbumID").Value
' The following will print results in the
'immediate window in the Visual Basic Editor.
' It needs to be replaced with whatever you
'want to do with the output data.
Debug.Print lngRowFound
End If
End If
Next
.MoveNext
Loop
End With
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Function
This will get very slow for the full number of columns and large
numbers of rows.
It requires that you pass it the pattern the user wants to search for.
It displays the AlbumID on row the search pattern was located, or 0 if
nothing at all.
The part that displays the AlbumID in the immediate window will have
to be changed to whatever form of data output/manipulation you
require.
Note: This was tested on only limited data, and for only a few
minutes. Please investigate further.
Note: If the complexity of the above is compared to my original
solution . . .
Sincerely,
Chris O.