I have a small company Database that tracks our repair orders. I have a query that I would like to execute based on criteria that the user inputs. I am new to VBA so most of my code is based on google research. I took a technique of wrapping my criteria variables with get/set functions. Supposedly, according to this site: http://msdn.microsoft.com/en-us/library/dd671279(v=office.12).aspx it is possible to reference the functions "Get______()" through the query if I specify them as in the example on that site (by calling the function in the criteria field of the design mode view of the query).
However I am getting this error when I click on one of the buttons which executes either of the instances of the "Whiteboard" query, I get the error of "Undefined function 'GetCustomer' in expression"
Not sure what I am doing here, it could be something really obvious. I have given a copy of my code below:
Option Compare Database
'declarations
Private argStatus As String
Private argCustomer As String
Private argManufacturer As String
Private argType As String
Private argDateFrom As Date
Private argDateUntil As Date
Public Sub SetStatus(Value As String)
argStatus = Value
End Sub
Public Sub SetCustomer(Value As String)
argCustomer = Value
End Sub
Public Sub SetManufacturer(Value As String)
argManufacturer = Value
End Sub
Public Sub SetType(Value As String)
argType = Value
End Sub
Public Sub SetDateFrom(Value As Date)
argDateFrom = Value
End Sub
Public Sub SetDateUntil(Value As Date)
argDateUntil = Value
End Sub
Public Function GetStatus()
GetStatus = argStatus
End Function
Public Function GetCustomer()
GetCustomer = argCustomer
End Function
Public Function GetManufacturer()
GetManufacturer = argManufacturer
End Function
Public Function GetType()
GetType = argType
End Function
Public Function GetDateFrom()
GetDateFrom = argDateFrom
End Function
Public Function GetDateUntil()
GetDateUntil = argDateUntil
End Function
Private Sub Cmd_ClearAll_Click()
'Clear all fields, except date
Chk_Status.Value = False
Chk_Customer.Value = False
Chk_Manufacturer.Value = False
Chk_Type.Value = False
Chk_Date.Value = False
Cmb_Status.Value = ""
Cmb_Customer.Value = ""
Cmb_Manufacturer.Value = ""
Cmb_Type.Value = ""
End Sub
Private Sub Cmd_SpecView_Click()
'Evaluate Check Boxes and Search Criteria
'If the checkboxes are checked, set value of Criteria
'Status
If Chk_Status.Value = True Then
SetStatus (Cmb_Status.Value)
End If
'Customer
If Chk_Customer.Value = True Then
SetCustomer (Cmb_Customer.Value)
End If
'Manufacturer
If Chk_Manufacturer.Value = True Then
SetManufacturer (Cmb_Manufacturer.Value)
End If
'Type
If Chk_Type.Value = True Then
SetType (Cmb_Type.Value)
End If
'Date Range
If Chk_Date.Value = True Then
SetDateFrom (Txt_DateFrom.Value)
SetDateUntil (Txt_DateUntil.Value)
End If
'Send these values to a query
DoCmd.OpenQuery ("Whiteboard")
End Sub
Private Sub Cmd_ViewStatus_Click()
'Opens Query
'Default Values Are Taken
DoCmd.OpenQuery ("Whiteboard")
End Sub
Private Sub Form_Load()
'Initializations
SetStatus ("*")
SetCustomer ("*")
SetManufacturer ("*")
SetType ("*")
SetDateFrom (#1/1/2001#)
SetDateUntil (Date)
End Sub