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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set some fields in a table to null

Status
Not open for further replies.

robdunfey

Technical User
Apr 26, 2002
110
GB
I have a complicated database with many tables, i dont want to alter the structure of the database as it isnt mine and I dont fully understand it. One table contains information that my client doesnt want me to see about their client but they want to see it before send the DB to me (get it :-!), so I want a button on a form that deletes this data. I have a table called SITEDATA and in it a field called phonenumber, I want to delete every value in the phonenumebr field, or reset them to a default.

If I were doing this manually I would delete the fields from the table and then add them again. Thus the table structure would remain unchanged, but the field would be empty. I think. Does anybody know how I can do this, and could somebody give me something to start with code wise. If there is a simple way to do this without programming great. I am very new to Access.

Rob
 
me.txtPkoneNo=Null

Note. Data update will not proceed if field have Primary key.

Aivars
 
Where do I put this code to refer to the table?
 
Those code you may put in sub program YourCommandButton_Click. This command updates text box txtPhoneNo on form. Accordingly current table field phonenumber (current shown phone No) will be updated if your form record source is set as query based on your table SITEDATA, and Control Cource of text box txtPhoneNo is field phonenumber.

private sub YourCommandButton_Click()
me.txtPhoneNo=Null
end sub


If you want to update the field phonenumber to Null for all records, which is selected by needed criteria, you can run update SQL (query).

private sub YourCommandButton_Click()
dim strSQL as string
dim strWhere as string

strWhere="Where MyCriteriaField = CriteriaValue"
strSQL="UPDATE SITEDATA SET phonenumber = Null "
strSQL=strSQL & strWhere & ";"
docmd.setwarnings false
docmd.runsql strsql
docmd.setwarnings true
end sub


Aivars [pipe]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top