I have the following VB code for a button that adds a new field, named after a textbox's value, then populates it with today's date in YYYY-MM-DD format for all entries
which runs fine for any value of text1 with just letters and numbers. But if I add a space, or other character, it gives me an error "syntax error in field definition".Code:DoCmd.RunSQL "ALTER TABLE tblMyTable ADD " & Text1.Value & " CHAR NULL" dat$ = Format(Now(), "yyyy-mm-dd") DoCmd.RunSQL "UPDATE tblMyTable SET " & Text1.Value & " = " & dat$ & " ;"
any ideas why? im still a bit of an access n00b so any help would be greatly appreciated. thanks!