def replace_in_tables(data, document, replacement):
    """
    Loops through tables in the document and replaces the field string with
    the replacement data from redcap form
    :param project: redcap.Project Object
    :param field: string object to search for in template document
    :param replacement: string of redcap field variable name
    :return: docx.Document object
    """
    for table in document.tables:
        for row in table.rows:
            for cell in row.cells:
                for para in cell.paragraphs:
                    para.text = para.text.replace(replacement, data.get(
                        replacement)) if not data.get(replacement
                        ) == None else para.text.replace(replacement, 'NA')
    return document
