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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • doaa bayoumy
    New Member
    • Apr 2011
    • 3

    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)

    Code:
    Private Sub Label15_Click()
    
    
    'purges the work file of the previous month
    DoCmd.OpenQuery "Purge Work File"
    
    'updates the work file with pay summary
    DoCmd.OpenQuery "Append to Temp"
    
    'opens the tax file
    Set a = CurrentDb.OpenRecordset("Tax")
    
    'opens the work file
    Set b = CurrentDb.OpenRecordset("Temp work")
    
    'updates the tax file
    Do While Not b.EOF()
    a.MoveFirst
    
        Do While Not a.EOF()
    
            If b.[Net Pay before tax] < a.[Income] Then
                Exit Do
        
            End If
    
            a.MoveNext
        Loop
        
        b.Edit
        b.[Tax] = a.[Tax]
        b.[Net Pay after tax] = b.[Net Pay before tax] - b.[Tax]
        b.Update
        b.MoveNext
        
    Loop
    
    'closes the tax file and the work file
    a.Close
    b.Close
    
    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
    Last edited by Niheel; Apr 5 '11, 09:08 AM.
  • Scorp Scorp
    New Member
    • Mar 2011
    • 40

    #2
    Okk
    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 ??

    Comment

    • TheSmileyCoder
      Recognized Expert Moderator Top Contributor
      • Dec 2009
      • 2322

      #3
      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.

      Comment

      • doaa bayoumy
        New Member
        • Apr 2011
        • 3

        #4
        I am using Access 2007; i will try your answer now

        Comment

        • Scorp Scorp
          New Member
          • Mar 2011
          • 40

          #5
          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 :)

          Comment

          • doaa bayoumy
            New Member
            • Apr 2011
            • 3

            #6
            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

            Comment

            Working...