filter records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have frmMain ( Record Source property = tblA, let's say) and frmSub (Record Source perperty = tblSubA) and frmSubSub (Record Source property = tblSubSubA) in a very simple form/subform/subsubform format: tblSubSubA has a FK to tblSubA and, tblSubA has a FK to tblA. I am using tables directly. It works well so far

I have another form frmSearch that has a combo box control on it: cboProd. When the user selects a product and clicks on cmdGO, I'd like to open frmMain with limited record set. I tried to use the Server Filter property of frmMain and it didn't work (tblA has ProdID as a FK)

"ProdID=" & Forms!frmSearch.Form!cboPro

I also tried to code ServerFilter in the cmdGO_Click event, it didn't work either

Private Sub cmdGO_Click(
DoCmd.OpenForm "frmMain
Forms!frmMain.Form.ServerFilter = "ProdID = " & Me.cboPro
Forms!frmMain.Form.Requer
Me.Visible = Fals
End Su

What's wrong???? Please help..
 
Access Project and SQL 2K

----- mike wrote: ----

I have frmMain ( Record Source property = tblA, let's say) and frmSub (Record Source perperty = tblSubA) and frmSubSub (Record Source property = tblSubSubA) in a very simple form/subform/subsubform format: tblSubSubA has a FK to tblSubA and, tblSubA has a FK to tblA. I am using tables directly. It works well so far

I have another form frmSearch that has a combo box control on it: cboProd. When the user selects a product and clicks on cmdGO, I'd like to open frmMain with limited record set. I tried to use the Server Filter property of frmMain and it didn't work (tblA has ProdID as a FK)

"ProdID=" & Forms!frmSearch.Form!cboPro

I also tried to code ServerFilter in the cmdGO_Click event, it didn't work either

Private Sub cmdGO_Click(
DoCmd.OpenForm "frmMain
Forms!frmMain.Form.ServerFilter = "ProdID = " & Me.cboPro
Forms!frmMain.Form.Requer
Me.Visible = Fals
End Su

What's wrong???? Please help..
 
Private Sub cmdGO_Click()
Dim strCriteria as String
strCriteria = "ProdID = " & Me.cboProd
DoCmd.OpenForm "frmMain", , , strCriteria
End Sub

If your ProdID field is not numeric, you may need to change
strCriteria to read "ProdID = '" & Me.cboProd & "'"

Cindy
 
Back
Top