T
Tal
Hi all,
Is there any way I can have a subform open up to a new record if nothing is
found by the search criteria that is filtering the main form?
Here is the search code
Also, I realize that I have the BeforeInsert event cancelled, but that is
because the address component of the search form is a concatenated read-only
expression, so it doesn't make sense to just let the user input a new client
or group at the bottom of the datasheet.
Many thanks,
Tal
Private Sub btnRefine_Click()
If Not IsNull(Me.txtSearch) Then
varWhere = varWhere & "([txtClientMainName] LIKE ""*" & Me.txtSearch &
"*"" OR " & _
"[txtClientFirstName] LIKE ""*" & Me.txtSearch & "*"" OR " & _
"[txtGroupName] LIKE ""*" & Me.txtSearch & "*"") AND"
End If
If Not IsNull(Me.txtRefine) Then
varWhere = varWhere & "([txtClientMainName] LIKE ""*" & Me.txtRefine &
"*"" OR " & _
"[txtClientFirstName] LIKE ""*" & Me.txtRefine & "*"" OR " & _
"[txtGroupName] LIKE ""*" & Me.txtRefine & "*"" OR " & _
"[compAddress] LIKE ""*" & Me.txtRefine & "*"")"
End If
lngLen = Len(varWhere)
If lngLen <= 0 Then
MsgBox "No Search Criteria Entered", vbInformation, "Nothing to Search."
Else
varWhere = Left$(varWhere, lngLen)
End If
Me.Filter = varWhere
Me.FilterOn = True
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
Cancel = True
MsgBox "You can't add new clients to the Search form", vbInformation,
"Permission Denied"
End Sub
Is there any way I can have a subform open up to a new record if nothing is
found by the search criteria that is filtering the main form?
Here is the search code
Also, I realize that I have the BeforeInsert event cancelled, but that is
because the address component of the search form is a concatenated read-only
expression, so it doesn't make sense to just let the user input a new client
or group at the bottom of the datasheet.
Many thanks,
Tal
Private Sub btnRefine_Click()
If Not IsNull(Me.txtSearch) Then
varWhere = varWhere & "([txtClientMainName] LIKE ""*" & Me.txtSearch &
"*"" OR " & _
"[txtClientFirstName] LIKE ""*" & Me.txtSearch & "*"" OR " & _
"[txtGroupName] LIKE ""*" & Me.txtSearch & "*"") AND"
End If
If Not IsNull(Me.txtRefine) Then
varWhere = varWhere & "([txtClientMainName] LIKE ""*" & Me.txtRefine &
"*"" OR " & _
"[txtClientFirstName] LIKE ""*" & Me.txtRefine & "*"" OR " & _
"[txtGroupName] LIKE ""*" & Me.txtRefine & "*"" OR " & _
"[compAddress] LIKE ""*" & Me.txtRefine & "*"")"
End If
lngLen = Len(varWhere)
If lngLen <= 0 Then
MsgBox "No Search Criteria Entered", vbInformation, "Nothing to Search."
Else
varWhere = Left$(varWhere, lngLen)
End If
Me.Filter = varWhere
Me.FilterOn = True
End Sub
Private Sub Form_BeforeInsert(Cancel As Integer)
Cancel = True
MsgBox "You can't add new clients to the Search form", vbInformation,
"Permission Denied"
End Sub