If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Combo Box Filter Help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-12, 04:36
paulb2012 paulb2012 is offline
Registered User
 
Join Date: Jan 2012
Posts: 1
Combo Box Filter Help

I have a table of 100 staff, I have added a filter on the form, ie users select name (from a unbound combo box) and is able to scroll through all records for that name. If no records have been created for MrA and you select that name in the filter I get a runtime error,

What do I need to add to my VB that will cancel the error and state –No Records held for that name then revert bank to showing all records

Private Sub CoName_AfterUpdate()
If IsNull(Me.CoName) Then
Me.FilterOn = False
Else
Me.Filter = "StafflName = """ & Me.CoName & """"
Me.FilterOn = True


Me.subfrm_frm_OpenActions.Form.Filter = "[StaffName] = " & Chr(34) & Me.CoName & Chr(34)

End If

End Sub
Reply With Quote
  #2 (permalink)  
Old 01-16-12, 06:42
myle myle is offline
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,143
the SubForm should be link to the Main form
by the

Link Child Fields
Link Master Fields

if these are full out the Database will keep everything in Sink you would have to do the

me.subfrm ..............
__________________
hope this help

See clear as mud


StePhan McKillen
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
Progaming environment:
Access based on my own environment: DAO3.6/A97/A2000/A2003
VB based on my own environment: vb6 sp5
ASP based on my own environment: 5.6
VB-NET based on my own environment started 2007
SQL-2005 based on my own environment started 2008
MYLE
Reply With Quote
  #3 (permalink)  
Old 01-18-12, 14:57
Sam Landy Sam Landy is offline
Registered User
 
Join Date: May 2004
Location: New York State
Posts: 931
I see the following few things I'm not too sure about in your code:

1 - What is the runtime error message?

2 - Why don't you filter the combobox to those personnel who have records in the table?

3 - Me.Filter = "StafflName = """ & Me.CoName & """" should read
Code:
Me.Filter = "StafflName = '" & Me.CoName & "'"
4. In the above statement, the field name is "StafflName" with an 'l' between the Staff and the Name. However, in the final statement, the field name seems to be StaffName, without the 'l'.

Sam
Reply With Quote
Reply

Tags
combo box, filtering

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On