Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Function & Cmd Button's On-Click Event

Status
Not open for further replies.

dmon000

Technical User
Sep 9, 2003
79
US
How can I get the following two functions to execute using the on-click event procudure of a command button? I need to use the values as criteria in a query. I have several different command buttons that use the same query, but need different criteria.

THANKS !!!

Function ReturnWard()
Dim MyVar1 As String
MyVar1 = "1"
ReturnWard = MyVar1
End Function

Function ReturnMeal()
Dim MyVar2 As Long
MyVar2 = 1
ReturnMeal = MyVar2
End Function
 



Hi,

Why would you use a function to return, essentially, a CONSTANT???

But more generally...
Code:
Sub Cmd_Click()
  Dim sSQL as string
  sSQL = "Select * From [TableA] " & _
         "Where [WardID]='" & ReturnWard() & "' And [MealNum]=" & ReturnMeal() & ""
End Sub


Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top