Results 1 to 4 of 4
  1. #1
    fullshape is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    2

    Calling fields into VBA Private Sub


    Hello all!
    I've placed a button in a form and in the Property Sheet, Event, On Click I've selected Event Procedure.
    I've tried a simple routine with just a MsgBox, that goes:
    Code:
    Private Sub NewReg_Click()    
        MsgBox ("hello")
    End Sub
    When I click the button in the Form View, it works and the messege appears. But I want the procedure to operate with some fields that I entry in the form. When I try to call a field of the form in the routine:
    Code:
    Private Sub NewReg_Click(Num_Entries)    
        MsgBox ("hello")
    End Sub
    I get the following error when I click the button:
    procedure declaration does not match description of event or procedure having the same name
    Does anybody know what the problem might be?
    Thank You

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    If you want something to happen when you do something in a control such as a textbox (that is bound to a field), you have to use an event applicable to that control.

    If you want to do something with a value already in a control via a command button, you need to reference that control in the code behind the button. For example, let's say that you want to assign the value of a control to a variable when you click a command button. The following code assigns the value in the control (the name of the specific control would have to be specified) to a variable called myvariable which is called out as being a string (text)

    Code:
    Private Sub NewReg_Click()    
    dim myvariable as string
     
    myvariable=me.mycontrolnamehere
     
    End Sub

  3. #3
    fullshape is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    2
    Thanks a lot! My problem was the second you described. Was. =) Thank You!

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calling Excel from Access
    By Terry Lawson in forum Programming
    Replies: 2
    Last Post: 02-06-2011, 05:07 AM
  2. Replies: 9
    Last Post: 12-20-2010, 08:05 PM
  3. calling function
    By ManvinderKaur in forum Programming
    Replies: 3
    Last Post: 07-22-2010, 10:53 PM
  4. Replies: 4
    Last Post: 03-31-2010, 03:41 PM
  5. Calling Query from different Access DB
    By Jerry8989 in forum Queries
    Replies: 4
    Last Post: 10-02-2009, 08:48 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