View Single Post
  #4 (permalink)  
Old September 22nd, 2011, 07:56 AM
dpm1057 dpm1057 is offline
Registered User
Points: 19, Level: 1
Points: 19, Level: 1 Points: 19, Level: 1 Points: 19, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Doesn't make sense

Hi Geoffrey,

Thanks for the response, but it does not make sense. Mostly because this is how the example provided in the sample database "Chamber Application" was written.

All I have done is change the 2 conditional IF statements to reflect the objects and tables I am filtering upon, and deleted the EnableDisableControls command since I am not using that.

This code works in the sample database, but it is not working when I try it with a date or text value from my database.

Public Sub SelectRecords()
On Error GoTo Error_Handler

Dim varWhereClause As Variant
Dim strAND As String

varWhereClause = Null
strAND = " AND "

If cboMemberStatusKey & "" <> "<all>" Then
varWhereClause = (varWhereClause + strAND) & _
"tblBusiness.MemberStatusKey = """ & _
cboMemberStatusKey & """"
End If

If Not IsNull(txtPaymentAmt) Then
varWhereClause = (varWhereClause + strAND) & _
"tblBusiness.BusinessKey IN (" & _
"Select BusinessKey From tblPayment Where" & _
" PaymentAmount = " & Me!txtPaymentAmt & ")"
End If

varWhereClause = " WHERE " + varWhereClause

Me.RecordSource = ReplaceWhereClause(Me.RecordSource, varWhereClause)
Me.Requery

EnableDisableControls

Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
DisplayUnexpectedError Err.Number, Err.Description
'MsgBox (Err.Number & ": " & Err.Description)
' simpler version without centralized error text
Resume Exit_Procedure
Resume


End Sub
Reply With Quote