Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

Help returning a value from a module to a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marty Newbe - 04 Nov 2006 05:10 GMT
Hi can someone tell me what I am doing wrong.
I am calling a function from within a form. The function is located in
module2.
The values pass to the function fine but the returned value from test2 is
alway 0.
Its probably a fundamental mistake but any help would be appreciated.

Option Compare Database
'Form
Option Explicit
Public Sub get_lib_num_Click()
Dim a, b, z As Integer
a = 5
b = 3
z = test2(a, b)
End Sub

'module2
Option Compare Database
Option Explicit

Public Function test2(ByVal x As Integer, ByVal y As Integer) As Integer
z = x + y

End Function
Duane Hookom - 04 Nov 2006 05:34 GMT
Try:
Public Sub get_lib_num_Click()
   Dim a As Integer, b As Integer, z As Integer
   a = 5
   b = 3
   z = test2(a, b)
End Sub

'module2
Option Compare Database
Option Explicit

Public Function test2(ByVal x As Integer, ByVal y As Integer) As Integer
   test2 = x + y
End Function

Signature

Duane Hookom
MS Access MVP

> Hi can someone tell me what I am doing wrong.
> I am calling a function from within a form. The function is located in
[quoted text clipped - 21 lines]
>
> End Function
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.