Results 1 to 7 of 7

Thread: What does this code mean?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509

    What does this code mean?

    Hi, being kind of new to coding aspect of Access, i am unware what this does. Can someone please give me a quick explanation? Especially the lines aceditmenu,

    Thanks

    VB Code:
    1. Option Compare Database
    2.  
    3. Private Sub Command31_Click()
    4. On Error GoTo Err_Command31_Click
    5.  
    6.  
    7.     DoCmd.GoToRecord , , acNewRec
    8.  
    9. Exit_Command31_Click:
    10.     Exit Sub
    11.  
    12. Err_Command31_Click:
    13.     MsgBox Err.Description
    14.     Resume Exit_Command31_Click
    15.    
    16. End Sub
    17. Private Sub Command32_Click()
    18. On Error GoTo Err_Command32_Click
    19.  
    20.  
    21.     DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    22.     DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    23.  
    24. Exit_Command32_Click:
    25.     Exit Sub
    26.  
    27. Err_Command32_Click:
    28.     MsgBox Err.Description
    29.     Resume Exit_Command32_Click
    30.    
    31. End Sub
    32. Private Sub Command33_Click()
    33. On Error GoTo Err_Command33_Click
    34.  
    35.  
    36.     DoCmd.Close
    37.  
    38. Exit_Command33_Click:
    39.     Exit Sub
    40.  
    41. Err_Command33_Click:
    42.     MsgBox Err.Description
    43.     Resume Exit_Command33_Click
    44.    
    45. End Sub

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509

    Re: What does this code mean?

    Hi, in regards to this, all i would like to do is: put two option boxes, if one is pressed then show in report 1 and if the other is pressed then show in report 2.

    How can i do this simply. Access is not my favourite program. I am good at VB, if there is any vb code without the aceditmenu commands.

    If it helps i would like to know what they mean please?

  3. #3
    New Member
    Join Date
    Jan 2005
    Posts
    3

    Re: What does this code mean?

    Private Sub Command32_Click()
    'The above difines the sub routine of the On Click propertry of a command button

    On Error GoTo Err_Command32_Click
    'During execution of the code, if there is an error, the running of the code will "GoTo" the sub routine Err_Command32_Click: At that time you will recieve a message that tells you what the error was.

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    'The code above is the default VBA that Access creates when a command button is created to delete a record. It tells the program to go to the Form Bar and activate the Edit Menu. From there, the numbered code describes the action to take. "8" tells the program to select the current record and the "6" tells the program to delete the currently selected record. The "acMenuVer70" coinsides with the version of access that you have to understand what the preceding code is that you asking it to do.

    Exit_Command32_Click:
    Exit Sub
    'This code exits the sub routine

    Err_Command32_Click:
    MsgBox Err.Description
    Resume Exit_Command32_Click
    'This code creates the message box to tell you about your error (if you have one)

    End Sub
    'This code ends the sub routine

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509

    Re: What does this code mean?

    This is somebody elses program, and poorly done. By the way, thanks for the explanation, 99% of it i understood, just the aceditmenu thing.

    What i don't get is,after you press add new records, it somehow,adds it to the report. I am assuming this would be done, by transfering it to a table and then the report picking up the info from the query table.
    Is that how it would work?

    If that is the case, then say i had 2 options, i printed to one report, and the other printed to the another report, then to do this i would have to have another query table and another report, is that correct?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509

    Re: What does this code mean?

    Hi again, require a bit of help. If i have several comboboxes, each getting data from other tables, how do i save the whole collection of the information into another table?

  6. #6
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: What does this code mean?

    Very poor - I hope its not a db used by a company (joke)


    The last post you put up, the best way is to make a table which holds all the unique IDs from the combo boxes (plus other fields if required for text input). As to the save you could either rely on access, or do it manually, these options have been discussed loads of times as bound or unbound forms.

    Search the forums, web or text books.

    If you code and have a problem, not related to this thread, make a new post and add in the code, people will assist you towards your goal.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509

    Re: What does this code mean?

    Lol it is one used by a company. But some idiot who made the program before, was exactly that an idiot. No programming experience what so ever.

    Took me ages to understand what was going on. One basic rule of programming is to rename components to meaningful names allowing others to have a better understanding. What this idiot do, leaves them.

    All i did was add another field, another report and another query.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width