Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Very Confused on how to Change Table

Status
Not open for further replies.

chris9

Programmer
Feb 11, 2003
32
US
I am doing a lot with an imported text file so I will start by explaining what I will be doing. I am having a user start by creating a table by entering information into a form. In my form they enter the name of the table and the name of the file to import. Click a button that converts the text into a table by running a macro so it if formated correctly. Next I am having them enter a new file name. When they select the next button the table is converted into xml from a vb program that I wrote. Here's my problem, sometimes the table has extra records without information that are halting the xml transformation.
I need to know how to remove these records is a certain field is empty or Null but I would like to do it when the table is created. Any ideas? I know this is easier than I am making it, but I am having trouble because the table name is generated in the form.

Thanks in advance for the help.
 
Docmd.runSQL "Delete From " & TableName & " Where Field Is null"

Is code that will delete the nulls from tableName for the field 'Field'.

If you put the code on the click event of your form...

Docmd.runSQL "Delete From " & Me!ControlCotainingTableName & " Where Field Is null"

Check out docmd.setwarnings in help. You can also convert your macro to code simply by going to Tools, Macro, Convert Macro to Visual Basic. Then you can copy and paste the code without guessing what it is (probably docmd.<ActionOfMacro>).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top