pauljkeenan
Programmer
Hi Guys
I am a newbie to Access and have bitten off more than I can chew with a project Im doing. I am in dire need of your expertise and would be eternally grateful (really) for any advice you can give.
I have a main form (frmVisaSearchMain), which contains various textboxes and combo boxes and a search button. Below this form there is a subform (frmVisaSearchsub) which should display the results of the search in datasheet view. At the moment it only displays a record table. Clicking on the search button should result in the subform displaying the appropriate record sheet. At the moment Im trying to do it for simple search, so just by a text box called "ref no". But it still doesnt work. Any ideas please guys?
I think the problem is with the refer to subform, because even when I try put the entire original table in ths sSql variable and display this, still nothing happens
private Sub Search_Click()
On Error Resume Next
Dim sSql As String
Dim sCriteria As String
sCriteria = "WHERE 1=1 "
Dim example As String
'This code is for a specific search where you will need to enter the exact string
'The source for this code can either be from a table or query
If Me![txtRefSearch] <> "" Then
sCriteria = sCriteria & " AND qrySearchVisaSub.Ref No like """ & txtRefSearch & """"
End If
If Nz(DCount("*", "qrySearchVisaSub", Right(sCriteria, Len(sCriteria) - 14)), 0) > 0 Then
sSql = "SELECT [Ref No]from qrySearchCriteriaSub " & sCriteria
Forms![frmSearchVisaMain]![frmSearchVisaSub].Form.RecordSource = sSql
Forms![frmSearchVisaMain]![frmSearchVisaSub].Form.Requery
End If
End Sub
I am a newbie to Access and have bitten off more than I can chew with a project Im doing. I am in dire need of your expertise and would be eternally grateful (really) for any advice you can give.
I have a main form (frmVisaSearchMain), which contains various textboxes and combo boxes and a search button. Below this form there is a subform (frmVisaSearchsub) which should display the results of the search in datasheet view. At the moment it only displays a record table. Clicking on the search button should result in the subform displaying the appropriate record sheet. At the moment Im trying to do it for simple search, so just by a text box called "ref no". But it still doesnt work. Any ideas please guys?
I think the problem is with the refer to subform, because even when I try put the entire original table in ths sSql variable and display this, still nothing happens
private Sub Search_Click()
On Error Resume Next
Dim sSql As String
Dim sCriteria As String
sCriteria = "WHERE 1=1 "
Dim example As String
'This code is for a specific search where you will need to enter the exact string
'The source for this code can either be from a table or query
If Me![txtRefSearch] <> "" Then
sCriteria = sCriteria & " AND qrySearchVisaSub.Ref No like """ & txtRefSearch & """"
End If
If Nz(DCount("*", "qrySearchVisaSub", Right(sCriteria, Len(sCriteria) - 14)), 0) > 0 Then
sSql = "SELECT [Ref No]from qrySearchCriteriaSub " & sCriteria
Forms![frmSearchVisaMain]![frmSearchVisaSub].Form.RecordSource = sSql
Forms![frmSearchVisaMain]![frmSearchVisaSub].Form.Requery
End If
End Sub