B
Breecy via AccessMonster.com
I have a button on my form to allow a user to search for a portfolio number.
The user enters the number and then clicks O.K. on the form. What I want to
happen is the form displays with the results. What currently happens is the
screen goes blank. Here is my code:
Form buttons:
Private Sub cmdCancel_Click()
DoCmd.Close acForm, frmSearchPortfolio
End Sub
Private Sub cmdOK_Click()
If txtPortSearch = "" Then
MsgBox " A portfolio number has not been entered." & vbCrLf & _
"Please enter a portfolio number or click cancel", vbOKOnly +
vbInformation
Else: txtPortSearch = strPortSearch
Call Search_Rec
DoCmd.Close acForm, "frmSearchPortfolio"
End If
End Sub
Sub Code:
Sub Search_Rec()
Dim strRsp As String
Dim strSQL As String
strSQL = "SELECT MASTER.PORTFOLIO_ID, MASTER.ACCOUNT_NAME, " & _
"MASTER.PORT_SHORT_NAME,MASTER.PRY_MGR_ID, CrossRef.Sg, " & _
"CrossRef.[Sg Dummy], tblxRefERS.ERS, tblxRefCID.Client_ID " & _
"FROM tblxRefCID RIGHT JOIN (tblxRefERS RIGHT JOIN (CrossRef INNER JOIN
MASTER ON CrossRef.P = MASTER.PORTFOLIO_ID) " & _
"ON tblxRefERS.FUND = CrossRef.FUND) ON tblxRefCID.FUND = CrossRef.FUND " & _
"WHERE(((MASTER.PORTFOLIO_ID)='" & strPortSearch & "'));"
Forms!frmMain.RecordSource = strSQL
Forms!frmMain.Recalc
Forms!frmMain.Refresh
End Sub
strPortSearch is a global variable. Any help is greatly appriciated.
The user enters the number and then clicks O.K. on the form. What I want to
happen is the form displays with the results. What currently happens is the
screen goes blank. Here is my code:
Form buttons:
Private Sub cmdCancel_Click()
DoCmd.Close acForm, frmSearchPortfolio
End Sub
Private Sub cmdOK_Click()
If txtPortSearch = "" Then
MsgBox " A portfolio number has not been entered." & vbCrLf & _
"Please enter a portfolio number or click cancel", vbOKOnly +
vbInformation
Else: txtPortSearch = strPortSearch
Call Search_Rec
DoCmd.Close acForm, "frmSearchPortfolio"
End If
End Sub
Sub Code:
Sub Search_Rec()
Dim strRsp As String
Dim strSQL As String
strSQL = "SELECT MASTER.PORTFOLIO_ID, MASTER.ACCOUNT_NAME, " & _
"MASTER.PORT_SHORT_NAME,MASTER.PRY_MGR_ID, CrossRef.Sg, " & _
"CrossRef.[Sg Dummy], tblxRefERS.ERS, tblxRefCID.Client_ID " & _
"FROM tblxRefCID RIGHT JOIN (tblxRefERS RIGHT JOIN (CrossRef INNER JOIN
MASTER ON CrossRef.P = MASTER.PORTFOLIO_ID) " & _
"ON tblxRefERS.FUND = CrossRef.FUND) ON tblxRefCID.FUND = CrossRef.FUND " & _
"WHERE(((MASTER.PORTFOLIO_ID)='" & strPortSearch & "'));"
Forms!frmMain.RecordSource = strSQL
Forms!frmMain.Recalc
Forms!frmMain.Refresh
End Sub
strPortSearch is a global variable. Any help is greatly appriciated.