'This is a VISUAL BASIC program, it would have to be converted to VBA access. 'Posted in newsgroup by Thomas Zapf-Schramm on 2000/04/07 'I'm working for years with SPSS amd MS Access. Because MS-Access has no labels in the SPSS sense we 'use lookup-tables to substitute this feature in database reports or data entry forms. 'When I go from Access To SPSS I need a tiny Visual Basic program '(In the Access database, but it could easily be converted To VB script Or SAX Basic) 'that converts the lookup-table To a SPSS-Syntax file which generates the desired labels. 'The lookup-table has four columns: "Varname", "Varlabel", "Value" And "Vallabel". 'It has an entry for each possible value of each variable in the main database table. 'The following VBA program needs a reference to the "Microsoft scripting runtime" for the filesystem Object. Option Compare Database Option Explicit Public Sub MakeLabels(LabelTable As String, OutFileName As String) Dim aktDB As DATABASE Dim aktRS As Recordset Dim fs As New FileSystemObject Dim Outfile As TextStream Dim currVar As String Dim currVal As String Dim currVarlab As String Dim currValLab As String Dim lastVar As String Set aktDB = CurrentDb Set aktRS = aktDB.OpenRecordset(LabelTable, dbOpenDynaset) Set Outfile = fs.OpenTextFile(OutFileName, ForWriting, True) aktRS.MoveFirst lastVar = "" Outfile.Write ("VARIABLE LABELS") Do While Not aktRS.EOF currVar = aktRS("Varname") currVarlab = aktRS("Varlabel") If currVar <> lastVar Then Outfile.WriteLine Outfile.Write (" " & currVar & " '" & currVarlab & "'") End If lastVar = currVar aktRS.MoveNext Loop Outfile.WriteLine (".") Outfile.WriteLine Outfile.Write ("VALUE LABELS") aktRS.MoveFirst lastVar = "" Do While Not aktRS.EOF currVar = aktRS("Varname") If lastVar <> "" Then currVar = "/" & currVar currVal = CStr(aktRS("Value")) currValLab = aktRS("Vallabel") If currVar <> lastVar Then Outfile.WriteLine Outfile.WriteLine (" " & currVar) Outfile.Write (" " & Format(currVal, "0000") & " '" & currValLab & "'") Else Outfile.WriteLine Outfile.Write (" " & Format(currVal, "0000") & " '" & currValLab & "'") End If If lastVar = "" Then currVar = "/" & currVar lastVar = currVar aktRS.MoveNext Loop Outfile.WriteLine (".") aktRS.Close Outfile.Close Set aktRS = Nothing Set aktDB = Nothing Set Outfile = Nothing Set fs = Nothing End Sub