|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Delete Command Button
I'm new to Access and VBA and I need assistance.
I'm building a form that has a subform. I have a delete button on the main form that is not allowing deletes from the subform. I used the command button wizard to build the delete button but it doesn't work. I've tried to add vba behind the button and it's not working either. I received an error message on: Dim mydb As Database Dim response As Integer Dim mydb As Database „³ it said Database was invalid Dim system As Recordset response = MsgBox("Delete current employee?", 289, "Verify Delete") If response = 1 Then Set mydb = DBEngine.Workspaces(0).Databases(0) Set system = mydb.OpenRecordset("Systems", DB_OPEN_TABLE) system.MoveFirst foundemp = 0 Do Until (system.EOF Or foundemp = 1) If (system![System Name] = Forms![SystemsEntry]![System Name]) Then foundemp = 1 Else system.MoveNext End If Loop Do Until (system.EOF) If (system![System Name] = Forms![SystemsEntry]![System Name]) Then system.Delete End If Loop system.Delete DoCmd.ShowAllRecords system.Close End If End Sub I've tried to add the delete button to the subform and it's not showing. If anyone can help me it is much appreciated. |
|
#2
|
|||
|
|||
|
Do you a have a DAO library referenced in you DB? ( For example Microsoft DAO 3.6 Library Object)
Also Dim mydb As Database Remove the "„³ " S- |
|
#3
|
|||
|
|||
|
S,
I don't think I have this anywhere. I have one form where the delete button is deleting from my table but that form doesn't have a subform so I'm thinking I have to specifiy the form somehow but I'm not sure how to do this. As for the "„³ " that was a comment I had in there to show I got an error on that line. |
|
#4
|
|||
|
|||
|
Can you post your DB?
S- |
|
#5
|
|||
|
|||
|
Delete Commad Button
The forms I'm having problems with are the SystemsEntry, TasksEntry and EmployeePayInformationDataEntry
|
|
#6
|
|||
|
|||
|
Delete Command Button
Sorry it's telling me my DB is too big. I even zipped it. Or, I get the "Page cannot be found".
|
|
#7
|
|||
|
|||
|
Turn on
Allow private message and I will sen you info for an ZTP site to upload it to as long as it is less then 5MB S0 |
|
#8
|
|||
|
|||
|
It's set to allow PM but not to send me email.
|
|
#9
|
|||
|
|||
|
Which form has this code in it? I can't find the code anywhere.
S- |
|
#10
|
|||
|
|||
|
The reason your VBA code didn't work (to start with) IS you haven't reference the DAO library
Go to you VB editor Tools References and put checks in the boces of the following libraries Microsoft DAO 3.6 Library Object S- Play with this. I am also attaching a DB that show code on how to delete a record using DAO, and ADO S- |
|
#11
|
|||
|
|||
|
Do you still need help or are you okay?
S- |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > Delete Command Button |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|