Z
Zetony
I need a code that can help me to do a multiple search in an unbound form.
Where the user can choose any texbox or combo and enter the appropriate
information and it will produce all the records in the table that pertains to
that information and populate it/ them to another form called the 'Edith
Record Form".
Please this is not using one parameter textbox or combo box to do a search,
rather it requires the user choosing from any of the 57 in the form, on
entering information specific to that textbox or combo all other records
concerning that information is retrieved from the table. The idea behind this
is a situation where the user cannot remember for instance a File number he
can search with any other information handy to him.
Though, right now I have this code below which can only search with
Filenumber. I have tried to use it with the Municipality and other parameters
in the table field and it is not working what am I doing wrong and how can I
correct it.
I know there are smart people out there that can help me. Thanks in advance.
Private Sub SEARCH_RECORD_Click()
On Error GoTo Err_SEARCH_RECORD_Click
This section is working great, finding any file number entered into the text
box and populating it to the Edit Form.
Dim stDocName As String
Dim stLinkCriteria As String
'Check to make sure a correct File Number was entered
Me.FILENO.SetFocus
If Me.FILENO.Text = "" Then
MsgBox "PLEASE ENTER A VALID FILENO", vbExclamation, "ACRP"
Exit Sub
End If
'Select records from Edit Record Form that match the selection criteria of
'a chosen File Number
Me.FILENO.SetFocus
If Me.FILENO.Text = "" Then
stLinkCriteria = "[FILENO] Like '*" & Me.STREET & "*' "
ElseIf Me.FILENO.Text <> "" Then
stLinkCriteria = "[FILENO] Like '*" & Me.STREET & "*' and [FILENO] =
'" & Me.FILENO & "' "
End If
This section of the code is not working! So what is it that I'm doing
wrongly. Because I have up to 50 parameters and objects that I have to work
with. Right now it's only one working.
'Check to make sure a correct Municipality was entered
'Me.MUNICIPALITY.SetFocus
'If Me.MUNICIPALITY.Text = "" Then
' MsgBox "PLEASE ENTER A VALID Municiplaity", vbExclamation, "ACRP"
' Exit Sub
'End If
'Select records from Edit Record Form that match the selection criteria of
'a Municipal
' Me.MUNICIPALITY.SetFocus
' If Me.MUNICIPALITY.Text = "" Then
' stLinkCriteria = "[MUNICIPALITY] Like '*" & Me.STREET & "*' "
'ElseIf Me.MUNICIPALITY.Text <> "" Then
' stLinkCriteria = "[MUNICIPALITY] Like '*" & Me.STREET & "*' and
[MUNICIPLAITY] = '" & Me.MUNICIPALITY & "' "
'End If
stDocName = "EDITRECORDFORM"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_SEARCH_RECORD_Click:
Exit Sub
Err_SEARCH_RECORD_Click:
MsgBox Err.Description
Resume Exit_SEARCH_RECORD_Click
End Sub
Where the user can choose any texbox or combo and enter the appropriate
information and it will produce all the records in the table that pertains to
that information and populate it/ them to another form called the 'Edith
Record Form".
Please this is not using one parameter textbox or combo box to do a search,
rather it requires the user choosing from any of the 57 in the form, on
entering information specific to that textbox or combo all other records
concerning that information is retrieved from the table. The idea behind this
is a situation where the user cannot remember for instance a File number he
can search with any other information handy to him.
Though, right now I have this code below which can only search with
Filenumber. I have tried to use it with the Municipality and other parameters
in the table field and it is not working what am I doing wrong and how can I
correct it.
I know there are smart people out there that can help me. Thanks in advance.
Private Sub SEARCH_RECORD_Click()
On Error GoTo Err_SEARCH_RECORD_Click
This section is working great, finding any file number entered into the text
box and populating it to the Edit Form.
Dim stDocName As String
Dim stLinkCriteria As String
'Check to make sure a correct File Number was entered
Me.FILENO.SetFocus
If Me.FILENO.Text = "" Then
MsgBox "PLEASE ENTER A VALID FILENO", vbExclamation, "ACRP"
Exit Sub
End If
'Select records from Edit Record Form that match the selection criteria of
'a chosen File Number
Me.FILENO.SetFocus
If Me.FILENO.Text = "" Then
stLinkCriteria = "[FILENO] Like '*" & Me.STREET & "*' "
ElseIf Me.FILENO.Text <> "" Then
stLinkCriteria = "[FILENO] Like '*" & Me.STREET & "*' and [FILENO] =
'" & Me.FILENO & "' "
End If
This section of the code is not working! So what is it that I'm doing
wrongly. Because I have up to 50 parameters and objects that I have to work
with. Right now it's only one working.
'Check to make sure a correct Municipality was entered
'Me.MUNICIPALITY.SetFocus
'If Me.MUNICIPALITY.Text = "" Then
' MsgBox "PLEASE ENTER A VALID Municiplaity", vbExclamation, "ACRP"
' Exit Sub
'End If
'Select records from Edit Record Form that match the selection criteria of
'a Municipal
' Me.MUNICIPALITY.SetFocus
' If Me.MUNICIPALITY.Text = "" Then
' stLinkCriteria = "[MUNICIPALITY] Like '*" & Me.STREET & "*' "
'ElseIf Me.MUNICIPALITY.Text <> "" Then
' stLinkCriteria = "[MUNICIPALITY] Like '*" & Me.STREET & "*' and
[MUNICIPLAITY] = '" & Me.MUNICIPALITY & "' "
'End If
stDocName = "EDITRECORDFORM"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_SEARCH_RECORD_Click:
Exit Sub
Err_SEARCH_RECORD_Click:
MsgBox Err.Description
Resume Exit_SEARCH_RECORD_Click
End Sub