vba keyboard delete key help

gheepok

Registered User.
Local time
Today, 22:51
Joined
Aug 29, 2010
Messages
13
i want to create a button that have delete key action.
this Application.Screen.PreviousControl = "" works on main form but does not works on subform.
please someone help.

 
1. Open up your Relationships
2. Right click anywhere inside and add all your forms to the screen
3. Right click the line that joins the two tables and select Edit Relationship...
4. Tick all three check boxes

If you don't see lines joining them then you don't have relationships setup and need to set it up.
 
yes i have the relationships but still have no luck.
i need a button that have have same action with delete key on a keyboard.
the button can works on main form and subform.
 
Show us a screenshot of your relationships. Also, is your subform linked via Link Master/Child Fields properties?
 
this is the screen shot of the relation ship.

vbaInet
i only need the keyboard delete key action code on a button.
 

Attachments

  • relationship.JPG
    relationship.JPG
    7 KB · Views: 126
I know what you need which is why I'm asking these questions.

I can see problems already with your relationships:

1. You've only got 2 tables and I'm not convinced this db is normalized.
2. Your user table doesn't have a primary key.

Can I see the join type between the two tables? Also, which table is your subform based on, user or asset?
 
in user table the id is foreign key.

the subform is user.

can you give i a sample on the vba code.
thanks.
 

Attachments

  • join type.JPG
    join type.JPG
    35.8 KB · Views: 115
Basically the delete button will only work if it is inside the subform. Drop a button on the subform and follow the wizard to get the delete button.

If you want to put the button in the main form then:
Code:
Currentdb.Execure "DELETE [FieldName] FROM [TableName] WHERE [ID] = " & Me![ID]
Me.SubformControlName.Requery
But this will fail if there's no current record. So my advice is follow my first suggestion.
 
i dont want to clear every field when click a button.

can we write a vba code that can clear a field at main form and subform.

do you have any sugguestion to clear a field at main form or subform with a button?

thanks.
 
Simply set the value of the field to Null

Me![FieldName] = Null
 

Users who are viewing this thread

Back
Top Bottom