Sub or Function not defined

root2007

New member
Local time
Tomorrow, 06:10
Joined
Jan 25, 2012
Messages
9
Hi,

I am new here and just started learning MS Access. I have a problem with the code I am doing now and the error is "Sub or function not defined" the code is:

Option Compare Database
Option Explicit

Private Sub AddToWhere(FieldValue As Variant, FieldName As String, MyCriteria As String, ArgCount As Integer)

If FieldValue <> "" Then
If ArgCount > 0 Then
MyCriteria = MyCriteria & " and "
End If

If FieldValue = "Null" Then
MyCriteria = (MyCriteria & FieldName & " Is Null ")
Else
MyCriteria = (MyCriteria & FieldName & " Like " & Chr(39) & FieldValue & Chr(42) & Chr(39))
End If

ArgCount = ArgCount + 1
End If

End Sub

Private Sub cmdClear_Click()
Dim MySQL As String
Dim Tmp As Variant

MySQL = "SELECT * FROM [search employee] WHERE False"

' Clear search text boxes.
Me![txtSearchDriver] = Null
Me![txtSearchDate] = Null
Me![txtSearchSite] = Null


Me![frmqryDeliveryTrans].Form.RecordSource = MySQL

Me![txtSearchDriver].SetFocus

End Sub

Private Sub DisableControl()

Dim Tmp As Variant

If Me![frmqryDeliveryTrans].Enabled Then
Tmp = EnableControls("Detail", False)
End If

End Sub

Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize

End Sub

Private Sub txtSearchDriver_AfterUpdate()

'DisableControl

End Sub

Private Sub cmdShowDetail_Click()
Dim MySQL As String, MyCriteria As String, MyRecordSource As String
Dim ArgCount As Integer
Dim Tmp As Variant

' Initialize argument count.
ArgCount = 0

' Initialize SELECT statement.
MySQL = "SELECT * FROM [qryDeliveryTrans] WHERE "
MyCriteria = ""

AddToWhere [txtSearchDriver], "[Driver Name]", MyCriteria, ArgCount
AddToWhere [txtSearchDate], "[Delivery Date]", MyCriteria, ArgCount
AddToWhere [txtSearchSite], "[Site]", MyCriteria, ArgCount

If MyCriteria = "" Then
MyCriteria = "True"
End If

MyRecordSource = MySQL & MyCriteria

Me![frmqryDeliveryTrans].Form.RecordSource = MyRecordSource

If Me![frmqryDeliveryTrans].Form.RecordsetClone.RecordCount = 0 Then
MsgBox "No records match the criteria you entered.", 48, "No Records Found"
Me!Clear.SetFocus
Else
Tmp = EnableControls("Detail", True) - this is where the error comes out.

' Move insertion point to Find REgister Subform.
Me![frmqryDeliveryTrans].SetFocus

End If

End Sub

Can you please tell me what to do. Thanks
 
Exactly where is the error.

Which line?
 
Hi Rain,

thank you for your time but I already figure out the error. Thanks and more power
 

Users who are viewing this thread

Back
Top Bottom