Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 3rd, 2004, 06:47 PM
Melissa_65 Melissa_65 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 12 Melissa_65 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question re-using command buttons

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.

Reply With Quote
  #2  
Old February 3rd, 2004, 07:59 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
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-

Reply With Quote
  #3  
Old February 3rd, 2004, 08:06 PM
Melissa_65 Melissa_65 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 12 Melissa_65 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for that....wizards and lots of different buttons it is then!!!

Reply With Quote
  #4  
Old February 3rd, 2004, 08:15 PM
Iraq n Baq Iraq n Baq is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Columbia, Missouri
Posts: 34 Iraq n Baq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 34 m 50 sec
Reputation Power: 5
Send a message via AIM to Iraq n Baq
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

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > re-using command buttons


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway