Passing field name as variable into SQL statement using vba in access RRS feed

  • Question

  • I'm fairly new to using VBA and I'm trying to query a table that is missing values and for each record in the table where the field is null, insert into another table the rowID, field name that's missing the value and an error description such as "required field missing". 

    Any pointers on ways to accomplish this would be very helpful, any ideas?

    Wednesday, July 23, 2014 2:26 PM

All replies

  • Something along the lines of,

    INSERT INTO yourSecondTable (theIDField, theDescription)
    SELECT yourFirstTable.theID, "Required Info. Missing" FROM yourFirstTable
    WHERE yourFirstTable.theField Is Null;

    Happy to help ! When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answered

    Friday, July 25, 2014 12:12 PM