Hi guys. I have a program that i want to add feild size and null constraint check on it and make it work on accesss 2000 . I be happy if some one help me modify this code so it generate Acess sql statements so that i be able to paste it in sql window of acces 2000 and it excutes. .Thanks
On click event that i used to call this function
Code:For Each T In db.TableDefs '''Skip the system tables If Left(T.Name, 4) <> "MSys" Then ''' this line determines the primary key of the table ''' by calling GetPk function from module pk = Left(GetPK(T, db), InStr(1, GetPK(T, db), "<-") - 1) cont = cont & ShowFields(T.Name) & vbCrLf & " primary key " & pk & vbCrLf & vbCrLf End If Next T ''' This line of code post the generated table statment to a massage box MsgBox contCode:Function ShowFields(pTable As String) As String Dim db As Database Dim rs As Recordset Dim I As Integer Dim j As Integer Dim n As Integer Dim NL As String Dim strHold As String, ST As String Dim x As Variant NL = Chr(13) & Chr(10) ' Define newline. Set db = CurrentDb Set rs = db.OpenRecordset(pTable) n = rs.Fields.Count ReDim x(n - 1, 1) As String ST = "Create Table " & pTable & vbCrLf For I = 0 To (n - 1) ST = ST & rs.Fields(I).Name & " " & FieldType(rs.Fields(I).Type) & "," & vbCrLfNext I rs.Close db.Close Set db = Nothing ShowFields = ST '' returns the fields name to main function End Function


Reply With Quote