Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform doesn't work

Status
Not open for further replies.

legs00

Programmer
Oct 17, 2001
36
CA
I have a subform that retrieves specific fields from a table depending on the criteria the user enters and the projectid that they select. Now I don't understand why it doesn't work!!!

Here is the code that I wrote when you press the Search button:



Private Sub cmdSearch_Click()

Dim strSearch As String
Dim strProjectId As String
Dim strSqlQry As String

If IsNull(cmbProjectID) Then
MsgBox "you must select a project"
cmbProjectID.SetFocus
Exit Sub
End If
If IsNull(txtSearch) Then
MsgBox "Must enter a criteria"
txtSearch.SetFocus
Exit Sub
End If

strSearch = txtSearch.Value
strProjectId = cmbProjectID.Value

Dim conn As ADODB.Connection
Set conn = CurrentProject.Connection

'get all the info that corresponds to the criteria and insert it into the temporary table
Dim rsQry As ADODB.Recordset
Set rsQry = New Recordset

strSqlQry = "Select * from activities where wbs like '" & strSearch & "' and projectid = '" & strProjectId & "'"
rsQry.Open strSqlQry, conn, adOpenStatic, adLockOptimistic

If strSearch = "*" Then
Form_CalculationsSubform.Form.RecordSource = "Select * from activities where wbs not like '_INITIAL' and projectid = '" & strProjectId & "'"
Else
Form_CalculationsSubform.Form.RecordSource = "Select * from activities where wbs like '" & strSearch & "' and projectid = '" & strProjectId & "'"
End If

End Sub


I don't understand why it doesn't work if i use another subform to retrieve something else but the criterias that I am using are the same.
 
Just before the line "End Sub", insert the following code:

Form_CalculationsSubform.Form.Requery


Seaport
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top