|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi there
here's hopefully a simple one from an absolute beginner with no coding experience trying to create a simple database using the wizards! I have a number of forms (each form is a bound form created using the form wizard, relating to a different table) that I want to put the same command buttons on: add new record and delete record. I have used the Control Wizards command button tool to create a button for one of the forms, have given it a name via the wizard and it works fine. I would like to simply re-use that button for all the other forms. So I thought I would switch off the Control Wizard and create a command button on another form that basically calls on the same Event Procedure. I have drawn the button, then gone to the Properties/Events tab, On Click option and chosen the code builder. When I get to the VB editing screen, the button name I previously created does not appear in the LH drop-down menu to choose from (where I thought it maybe would!!). I'm obviously making a simple mistake somewhere, cos' I'm sure there should be a quick and easy way to assign common event procedures (add/delete) to buttons on different forms, without having to use the wizard to create a new add and new delete button for each form. Hmmmm....thanks very much for your help. ![]() |
|
#2
|
|||
|
|||
|
I would create some Public Subs in a Module to call on. In these Public Subs copy the code you wish to execute in each module. Then in your form call that public sub
However, for bound forms, this is overkill for the size and type of DB you are designing and I wouldn't waste my time, as the wizard a very easy way to do what you are wanting to do. S- |
|
#3
|
|||
|
|||
|
Thanks for that....wizards and lots of different buttons it is then!!!
|
|
#4
|
|||
|
|||
|
Melissa,
The button functions created using the button wizard don't transfer to copies of the button. The easiest way to accomplish what you want to do would be to create a macro called "Add Record" and choose GoToRecord as the Action. At the bottom of the macro design screen, there will be four settings. Set the Record line to "New." Save the macro and close it. Now create your first button (w/o the wizard), go to the properties box to the Event tab, and choose the line for OnClick. Your macro "Add Record" will be listed there. If you copy and paste the button now, the macro should stay attached on copies of the button. I'm not sure how to handle the Delete Record button issue. <Stop here if you don't understand Queries> My only thought would be to create an extra field in all of your tables called DelMark, create a macro called Delete Record, choose the SetValue action and put "DelMark" in the Item line, and "0" in the Expression line. Attach this to a new button in the same manner as above. This just marks each record for deletion - it doesn't actually delete anything. You'll have to setup a Delete Query for each table you're using, and add only the DelMark field to the query. Set the Criteria under the DelMark column to "0". You can then create another macro to run all of your Delete Queries on another button click, or on open/close of the database. How many forms are you making? Seems like overkill to try to work around the wizard for just a few forms. Hope this helps (and I hope everything I said is accurate).
__________________
--Slaughter slaughter@mizzou.edu |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > re-using command buttons |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|