Can anyone tell me why the folloing code only works sometimes? I tested it without the Recorset Set loop and it would work sometimes, but not others. In one case I put a MSGBOX infront of and behind the code where I set the description. I ran it and it worked. I changed nothing and I ran it again and got "Runtime 3270 - Property not found" on the line where the dscription is set. Any suggestions?
Public Sub UpdateProperties()
Dim dbs As Database
Dim rst As DAO.Recordset 'Using DAO to Create the needed table
Dim sql As String
Set dbs = CurrentDb
sql = "Select * from tblNewTransaction"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(sql, dbOpenDynaset, dbReadOnly)
Do Until rst.EOF = True
If rst.Fields("Required") = "YES" Then
dbs.TableDefs("Contacts").Fields(rst.Fields("FieldName")).Required = True
End If
dbs.TableDefs("Contacts").Fields(rst.Fields("FieldName")).Properties("Description") = rst.Fields("Description")
rst.MoveNext
Loop
rst.Close
dbs.Close
End Sub
Thank You,
sabloomer
Public Sub UpdateProperties()
Dim dbs As Database
Dim rst As DAO.Recordset 'Using DAO to Create the needed table
Dim sql As String
Set dbs = CurrentDb
sql = "Select * from tblNewTransaction"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(sql, dbOpenDynaset, dbReadOnly)
Do Until rst.EOF = True
If rst.Fields("Required") = "YES" Then
dbs.TableDefs("Contacts").Fields(rst.Fields("FieldName")).Required = True
End If
dbs.TableDefs("Contacts").Fields(rst.Fields("FieldName")).Properties("Description") = rst.Fields("Description")
rst.MoveNext
Loop
rst.Close
dbs.Close
End Sub
Thank You,
sabloomer