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

Deleting a record

Status
Not open for further replies.

nim180

IS-IT--Management
Aug 11, 2005
161
AU
Hi everyone, im hoping someone can help me with the following. I have a table with a users login details called "tbllogin". I have created a form which allows the admin to delete a user but the delete button won't seem to work? I have a combobox on the form which lists all the username that comes from "tbllogin", when a username is selected from the combobox and the delete button is clicked i would like the record to be deleted? my primary key in the table is "strUserName. Thanks in advance

Nim
 
How are ya nim180 . . .

Try this:
Code:
[blue]   Dim db As DAO.Database, SQL As String
   
   Set db = CurrentDb
   SQL = "DELETE strUserName " & _
         "FROM tbllogin " & _
         "WHERE ([strUserName] = '" & Me!ComboName.Column(0) & "';"
   db.Execute SQL, dbFailOnError
   
   Set db = Nothing[/blue]


Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Hey TheAceMan1, first of i would like to thank you, i actually have learned alot over the year just reading your replies from threads, 2 thumbs up for that:) secondly i read one of your previous replies which you gave the same code, i tried to apply it to my form but it didnt work. When i click the delete button nothing happens. I have placed the code into the onclick event! any clues?

nim
 
hey TheAceMan, just got that working with a bit of fiddling thank you
 
[blue]Beautiful! Absolutely Beautiful![/blue] [thumbsup2]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top