469,267 Members | 1,085 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

I want to view the VB code of my MS Access Database 2007?

Is there any way i can view the VB code of all the objects i created in my MS Access Database?; in the Event Procedure of any object; it only shows me the events; not the actual design?

p.s. i created the DB using wizards

You see i created this MS Access Database (assignment) using wizards to create all my Tables; Forms; Queries and Reports ; now my teacher is asking for the VB code (the object design code); i can get to the SQL commands for forms and queries but not the actual design code of a certain object for example (from another database)

Expand|Select|Wrap|Line Numbers
  1. Private Sub Label15_Click()
  4. 'purges the work file of the previous month
  5. DoCmd.OpenQuery "Purge Work File"
  7. 'updates the work file with pay summary
  8. DoCmd.OpenQuery "Append to Temp"
  10. 'opens the tax file
  11. Set a = CurrentDb.OpenRecordset("Tax")
  13. 'opens the work file
  14. Set b = CurrentDb.OpenRecordset("Temp work")
  16. 'updates the tax file
  17. Do While Not b.EOF()
  18. a.MoveFirst
  20.     Do While Not a.EOF()
  22.         If b.[Net Pay before tax] < a.[Income] Then
  23.             Exit Do
  25.         End If
  27.         a.MoveNext
  28.     Loop
  30.     b.Edit
  31.     b.[Tax] = a.[Tax]
  32.     b.[Net Pay after tax] = b.[Net Pay before tax] - b.[Tax]
  33.     b.Update
  34.     b.MoveNext
  36. Loop
  38. 'closes the tax file and the work file
  39. a.Close
  40. b.Close
  42. End Sub
is there a VB code for my DB in the first place?; i can send you the database if u like; but i dont think it attached here; skype: doaa.bayoumy
Apr 5 '11 #1
5 20369
First of all when you create a Database no code is associated with it.

Open your database file, then hold the Alt Key and press F11. A window will open (Microsoft Visual basic) enviroment platform. where you can write code.

The code you have provided in your question, is associated to a group of controls, like buttons, comboboxes, and other controls.

Coding is associated with events, in your database you have no events which means you have no code.

which access you are using 2003?? 2007 ??
Apr 5 '11 #2
2,321 Expert Mod 2GB
Hi doaa bayoumy and welcome to BYTES.

As such, a starting standard database will not come with Visual Basic code.

You can then start adding command buttons, or adding code to certain events to expand the functionality of your database. The code you posted is an example of such.

The normal loading/unloading and saving of records is all handled by access behind the scenes and that part of the code is not visible. Again you can choose to modify the standard saving by using unbound form, and use your own code to handle the loading and saving of records.
Apr 5 '11 #3
I am using Access 2007; i will try your answer now
Apr 5 '11 #4
As a start to let u see whats going on :
1)select one ofthe forms in your database
2)open it in design view
3)Select the button control from the toolbar
4) draw a square on your form
5)Click cancel if the Command Button Wizard window appear
6) Select event from the Property Sheet of that button
7) Point to OnClick
8) click on the dotted button next to it
9) a Choose Builder will appear
10) double click on Code Builder

And here you are , this represents will show you the code behind this button.

you can code whatever you need here . so that when that button clicked on your form the code will run.

hope that helped as a start :)
Apr 5 '11 #5
thanks alot Scorp this really did help; i guess i will have to invent some type of Event to make my teacher happy "he wants to see a code" embeded macros are not enough!

Thanks alot
Apr 5 '11 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Russell Read [MSFT] | last post: by
reply views Thread by Fernando Lopes | last post: by
5 posts views Thread by Seok Bee | last post: by
9 posts views Thread by Wayne Smith | last post: by
14 posts views Thread by SimeonD | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.