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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Filter Problem

Status
Not open for further replies.

sk1hotpepr

Technical User
Jul 11, 2003
63
US
I set up a filter for a combo box on my form but I'm trying to figure out why when I click in my combo box and choose what I want to filter, it won't filter the first time. If I click an item to filter a second time, then it will work. Has anyone seen this/ know what I'm doing wrong? Here's my combo box code:
Code:
Private Sub Combo125_AfterUpdate()
Dim myStr As String

Me.Combo125.SetFocus
myStr = Me.Combo125.Value

Me.Filter = "ContractorID = " & myStr & " AND ProjectNumber = '" & Me.ProjectNum & "'"
Me.FilterOn = True
Me.Refresh
End Sub
 
How are ya sk1hotpepr
[ol][li]If [blue]ContractorID[/blue] is [purple]text[/purple] try this:
Code:
[blue]   Dim myStr As [purple]String[/purple]
   
   myStr = Me.Combo125

   [purple]Me.FilterOn = False[/purple]
   Me.Filter = "ContractorID = '" & myStr & "' AND ProjectNumber = '" & Me.ProjectNum & "'"
   Me.FilterOn = True[/blue]
[/li]
[li]If [blue]ContractorID[/blue] is [purple]numeric[/purple] try this:
Code:
[blue]   Dim myStr As [purple]Integer[/purple]
   
   myStr = Me.Combo125

   [purple]Me.FilterOn = False[/purple]
   Me.Filter = "ContractorID = " & myStr & " AND ProjectNumber = '" & Me.ProjectNum & "'"
   Me.FilterOn = True[/blue]
[/li][/ol]

Calvin.gif
See Ya! . . . . . .
 
HeyYa AceMan!

Thanks for the tip, at first it didn't work when I tried that, but I had to set the DoCmd.OpenForm event to acFormEdit also. Now it's working. I just need to fix it so that nothing shows until a user picks a contractor from the combo box.

Have a great weekend!
[ponytails]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top