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!

Delete record popup form

Status
Not open for further replies.

jer007

Technical User
Feb 16, 2004
94
CA
On my main form (frmApplication) I have a delete records button. The onclick command is to open a popup form that prompts the user for a password before deleting the record. I have the correct password stored in tblpassword. I've taken a shot at the code for how to delete the record from the popup form but it's not working at all. I keep getting a compile error on the code below in red.

If you can take a look at this code and let me know what you think may work I'd appriciate the help. Thanks!

Private Sub cmbDelete_Click()
Dim StrPw As String
StrPw = tblpassword!password
If txtPassword = StrPw Then
DoCmd.RunCommand acCmdDeleteRecord Me.frmApplication
Else
MsgBox "Invalid Password"
End If
End Sub


 
if the record that needs to be deleted is the current record on the form then the following code willw ork

with forms!frmApplications.recordset
.delete
.update
end with

that should delete the current record from the forms recordset.
 
Hi!

Another workaround here is to do the following:

[tt] Forms!frmApplication.SetFocus
DoCmd.RunCommand acCmdDeleteRecord[/tt]

- setting focus to the form, then perform the delete

Roy-Vidar
 
Thanks, those both sound like good ideas.

When I run the code (I provided) above I get the following error "Run-time error '424': Object required."

This error occurs at the line StrPw = tblpassword!password

I'm trying to assign variable StrPw with the password stored in table: tblpassword, field: password.

How would I properly assign this variable?
 
Yes, you can't reference a value in a table like that, you'll need to either retrieve it thru a recordset, or for instance use a DLookup to fetch it.

For instance:

[tt]if not isnull(dlookup("password", "tblpassword","password = '" & txtpassword & "'")) then[/tt]

- typed not tested

Roy-Vidar
 
RoyVidar

Thanks, That code works great!

I appriciate the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top