Advertisement
Advertisement
| 06.05.2008 at 03:03PM PDT, ID: 23462081 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: |
Function fnGetFieldsOfTable(sTable As String) As Boolean
'fn to create table holding field names of input table parameter
Dim d As DAO.Database, f As Field, t As TableDef, sql As String
Dim r As DAO.Recordset
Dim sTemp As String
sTemp = "tmpTableFieldList"
Set d = CurrentDb
Set t = d.TableDefs(sTable)
On Error Resume Next
DoCmd.DeleteObject acTable, sTemp
On Error GoTo errH
'create table
sql = "select '1' as TableName, '1' as FieldName into " & sTemp & " from " & sTable & " where 1 = 0"
Debug.Print sql
d.Execute sql
Set r = d.OpenRecordset(sTemp)
For Each f In t.Fields
r.AddNew
r!tablename = sTable
r!FieldName = f.Name
r.Update
Next
Set r = Nothing
Set f = Nothing
Set d = Nothing
Exit Function
errH:
Beep
MsgBox Err & " " & Err.Description
Set d = Nothing
End Function
|