Hi -
I'm getting 'wrapped around the axle' trying to programatically create a unique index, sorted descending.
The following code snipped illustrates the problem. As far as I can tell, the "Create Unique Index" statement is straight out of the Help File. It all processes just fine -- no errors. The sub is called with:
call FillList("tblTemp")
However, the index is not created. The created table has just one field. There's no problems with multiple fields.Can anyone spot where I'm going wrong.
Thanks in advance -- Bob
I'm getting 'wrapped around the axle' trying to programatically create a unique index, sorted descending.
The following code snipped illustrates the problem. As far as I can tell, the "Create Unique Index" statement is straight out of the Help File. It all processes just fine -- no errors. The sub is called with:
call FillList("tblTemp")
However, the index is not created. The created table has just one field. There's no problems with multiple fields.Can anyone spot where I'm going wrong.
Code:
Public Sub FillList(pTable As String)
Dim db As database
Dim rs As Recordset
Dim rs2 As Recordset
Dim strSQL As String
Dim strHold As String
Dim n As Integer
On Error Resume Next
'WARNING: Table pTable will be deleted,
' and recreated. If this is
' a problem, choose another,
' unique table name.
CurrentDb.Execute "DROP TABLE " & pTable & ";"
strSQL = "CREATE TABLE " & pTable & " " _
& "( Selection Text(20) Not Null );"
Debug.Print strSQL
CurrentDb.Execute strSQL
CurrentDb.TableDefs.Refresh
Set db = CurrentDb
[COLOR="Red"]strSQL = "CREATE UNIQUE INDEX SelColor ON " & pTable & " ([Selection]) DESC;"
'Debug.Print strSQL
db.Execute strSQL[/COLOR]....
Thanks in advance -- Bob