G
Guest
Hi all, hope someone can help me.
I have a dB where the user can click a button to open a search form. Here
he/she types the search data into say the "Customer" field, then hits return
and the first form is returned with that record shown. Great so far, the
problem is that the "Customer" may have two parts to the name I.E., Joe
Smith. now this is not found when Joe or Smith is typed in only Joe Smith.
Is there a relatively simple way to have access look into the field for just
part of the data, i.e. Smith.
Here is the code for the unbound text box: txtFindCust
Private Sub txtFindCust_BeforeUpdate(Cancel As Integer)
'Check the Customer Name Exists before running the After Update
Dim strCustomer As String
If Not IsNull(Me.txtFindCust) Then
strCustomer = "[Customer] = '" & Me.txtFindCust & "'"
If IsNull(DLookup("Customer", "Sort Records Query - By Customer",
strCustomer)) Then
Cancel = True
MsgBox "No such entry." & vbCrLf & _
"Correct the entry, or press <Esc> to undo.", , "Error"
End If
End If
End Sub
Private Sub txtFindCust_AfterUpdate()
'Find a Customer Name
Dim strCustomer As String
If Not IsNull(Me.txtFindCust) Then
strCustomer = "[Customer] = '" & Me.txtFindCust & "'"
'Close this form
DoCmd.Close
'Make the RELEASE Button, Label Visible visible
Forms!ViewEditData.cmdReleaseFilter.Visible = True
Forms!ViewEditData.lblRecordLocked.Visible = True
'Open the Edit form at the appropriate record
DoCmd.OpenForm "ViewEditData", , , strCustomer
End If
End Sub
I thought of replacing the = with LIKE in the [Customer] = '" &
Me.txtFindCust part but this does nothing although it still works for the
whole search. I have tried entering *smith* into the box and this is not
found.
Any ideas?
--
Cheers
Chas
***************
* Spectrum is Green *
***************
I have a dB where the user can click a button to open a search form. Here
he/she types the search data into say the "Customer" field, then hits return
and the first form is returned with that record shown. Great so far, the
problem is that the "Customer" may have two parts to the name I.E., Joe
Smith. now this is not found when Joe or Smith is typed in only Joe Smith.
Is there a relatively simple way to have access look into the field for just
part of the data, i.e. Smith.
Here is the code for the unbound text box: txtFindCust
Private Sub txtFindCust_BeforeUpdate(Cancel As Integer)
'Check the Customer Name Exists before running the After Update
Dim strCustomer As String
If Not IsNull(Me.txtFindCust) Then
strCustomer = "[Customer] = '" & Me.txtFindCust & "'"
If IsNull(DLookup("Customer", "Sort Records Query - By Customer",
strCustomer)) Then
Cancel = True
MsgBox "No such entry." & vbCrLf & _
"Correct the entry, or press <Esc> to undo.", , "Error"
End If
End If
End Sub
Private Sub txtFindCust_AfterUpdate()
'Find a Customer Name
Dim strCustomer As String
If Not IsNull(Me.txtFindCust) Then
strCustomer = "[Customer] = '" & Me.txtFindCust & "'"
'Close this form
DoCmd.Close
'Make the RELEASE Button, Label Visible visible
Forms!ViewEditData.cmdReleaseFilter.Visible = True
Forms!ViewEditData.lblRecordLocked.Visible = True
'Open the Edit form at the appropriate record
DoCmd.OpenForm "ViewEditData", , , strCustomer
End If
End Sub
I thought of replacing the = with LIKE in the [Customer] = '" &
Me.txtFindCust part but this does nothing although it still works for the
whole search. I have tried entering *smith* into the box and this is not
found.
Any ideas?
--
Cheers
Chas
***************
* Spectrum is Green *
***************