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

How to erase data in DB 3

Status
Not open for further replies.

FreeJim

Programmer
Jul 26, 2001
7
CH
Hi,

I actually have a problem, I really want to erase a data, but I don't know how to specify which data, and how to erase. For example, if I have a modifiable zone liste, and select a data, I want to click on a button to erase it. The data, will already be in the table in the DB.

Does anyone known how to do that ?

Thanks in advance !
 


Have you looked into 'delete queries'?


Stew

 
For Access 97 use

Dim dbs As Database
Dim SQLLine As String

Set dbs = CurrentDB

SQLLine = "DELETE * FROM
WHERE [WHERE CLAUSE]"

dbs.Execute SQLLine

In the where clause you can use fields from the form
example:

"Date = " & Me.Date & ".....etc"

For litteral strings use triple quotes

"Name = """ & Me.Name & """....etc"

Me points to the current form date and name point to controls.

Hope this helps you....

Grtz,

Kalin
 
lot of thanks !

It really was that I need...
 


Personally, I wouldn't do this in code unless I really had to.

If you can do it in the QBE then the db is easier to understand and code has a habit of being stuffed in the oddest places and difficult to find.

Remember that Access has quite powerful facilities (accepts parameters, DDL, DML, Select Top x, Aggregate functions etc etc)

These Queries can be called from code when required.

Most important of all, they are easy to use especially for non-technical types.

Just an opinion.


Stew

 
Okay Stew,

But how do you write it in the QBE ? I already try to do it, but unfortunately I can't.

Can you help me ?

 


Hi FreeJim

QUERY|DELETE QUERY

Right click on Query and select PARAMETERS. Add a parameter and data type. This will popup as a silly msgbox with parameter name before query starts to run. Use this if you want user input. Then use parameter in criteria.

If you just want to take data from a form. Just enter in criteria something like, Forms!frmFormName!txtTextBoxName.

The button will then just need code like docmd.openquery "qryQueryName".

Hey, congratulations on your promotion.


Stew



 
Thanks for the help !

It wasn't a promotion, I just register :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top