Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    nkenney is offline Advanced Beginner
    Windows 2K Access 2007
    Join Date
    Mar 2009
    Posts
    40

    Question On-Click event transfer

    Hello,
    I am hoping you can help me. I am using Microsoft access 2007. I have created a command button which when I click it, I would like to go to another form. I have created a On-Click Event with the following code:
    Private Sub menu3_Click()
    On Error GoTo Err_menu3_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "Item Code"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_menu3_Click:
    Exit Sub
    Err_menu3_Click:
    MsgBox Err.Description
    Resume Exit_menu3_Click
    End Sub
    I have added MsgText commands After the Dim statements and nothing occurs. Any ideas as to what I am doing wrong?


    Thank you in advance!
    Nancy

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Hi Nancy,
    When you go to the menu3 control in design mode and right click and go to the Event tab, what does it say next to the Click event?

  3. #3
    nkenney is offline Advanced Beginner
    Windows 2K Access 2007
    Join Date
    Mar 2009
    Posts
    40

    ??? Sorry I am confused

    When I go to the Event tab, on the on-click it says [Event Procedure] and when I click on the button, it takes me to the event. Is this correct?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Absolutely correct! Post the code here starting with Private Sub and finish at End Sub

  5. #5
    nkenney is offline Advanced Beginner
    Windows 2K Access 2007
    Join Date
    Mar 2009
    Posts
    40

    Here you go...

    Private Sub menu3_Click()
    On Error GoTo Err_menu3_Click
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Item Code"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_menu3_Click:
    Exit Sub
    Err_menu3_Click:
    MsgBox Err.Description
    Resume Exit_menu3_Click

    End Sub

  6. #6
    rommelgenlight is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2009
    Posts
    77
    check your if have a form named exactly "item code". verify if it is correct. if not, change it. compile and run again.

  7. #7
    nkenney is offline Advanced Beginner
    Windows 2K Access 2007
    Join Date
    Mar 2009
    Posts
    40

    Compile?

    I have never compile a form before to get this to work. Is this new? How do I get it to compile?

    Thanks!

  8. #8
    rommelgenlight is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2009
    Posts
    77
    my advice nkenny with your codes, actually what you've done is best practice however if you dont need to use DIM then don't.

    anyway have you checked if you have a form exactly named "item code" ? if there is difference then change your stdocname to what is the real form name.

    Compiling is not new. Compiling is also a way of checking if your codes are correct as checked by ms access application. This is also called debugging.

    To do compiling, if you are in the microsoft visual basic environment on which you do your coding, go to Debug on the Menubar and click compile.

    let me know if you have opened your item code form already.

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Put this code in place of the original code and see what happens.
    Code:
    Private Sub menu3_Click()
       On Error GoTo Err_menu3_Click
       Dim stDocName As String
       Dim stLinkCriteria As String
       MsgBox "The Click code is executing"
       stDocName = "Item Code"
       DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_menu3_Click:
       Exit Sub
    Err_menu3_Click:
       MsgBox Err.Description
       Resume Exit_menu3_Click
    End Sub

  10. #10
    rommelgenlight is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2009
    Posts
    77
    Quote Originally Posted by rommelgenlight View Post
    my advice nkenny with your codes, actually what you've done is best practice however if you dont need to use DIM then don't.

    anyway have you checked if you have a form exactly named "item code" ? if there is difference then change your stdocname to what is the real form name.

    Compiling is not new. Compiling is also a way of checking if your codes are correct as checked by ms access application. This is also called debugging.

    To do compiling, if you are in the microsoft visual basic environment on which you do your coding, go to Debug on the Menubar and click compile.

    let me know if you have opened your item code form already.

    let us do this first.

  11. #11
    nkenney is offline Advanced Beginner
    Windows 2K Access 2007
    Join Date
    Mar 2009
    Posts
    40

    Question Compiled and did not see the message

    It compiled fine. I added the msgbox after my dim statement and nothing happened. Do I need to do something at the form? This looked simple but has gotten confusing.

  12. #12
    rommelgenlight is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2009
    Posts
    77
    what is the exact name of your table? maybe you could try to attach your db so I can check it.

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did you enable code to run yet?

  14. #14
    nkenney is offline Advanced Beginner
    Windows 2K Access 2007
    Join Date
    Mar 2009
    Posts
    40

    Exclamation I now know what it is, but have a question on this

    What occured is I started with a database I did about 3 years ago for another client. It created a .mdb file. I could load it in with no problems and everything but the push button code worked fine.

    Today, I decided to create a new database (.accdb file) and created On-Click push button code and it worked fine. My question, this will be a bit of a pain to recreate. I was wondering if there was something I could do to upgrade the database instead recreating it from scratch?

    Thank you for all of your help!

  15. #15
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You can import the old db into your .accdb or simply run it from ac2007.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Transfer text
    By nshaikh in forum Import/Export Data
    Replies: 0
    Last Post: 09-11-2008, 03:27 AM
  2. form_current event question
    By edo in forum Forms
    Replies: 0
    Last Post: 09-08-2008, 02:54 PM
  3. Form Event Question
    By protean_being in forum Forms
    Replies: 3
    Last Post: 05-06-2008, 10:43 AM
  4. Replies: 3
    Last Post: 04-23-2006, 09:09 PM
  5. File path name using Transfer spreadsheet
    By JohnN in forum Import/Export Data
    Replies: 0
    Last Post: 11-14-2005, 06:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums