473,490 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem using listbox filter if no record for field is present

2 New Member
I am new to access and am having a problem with filtering. Here is a little bit of my setup: I have a main form that has a listbox so that users can choose one or many groups in which to display information about. The control name of the listbox is "grupos". The name of the field it is sorting is "Grupo_Nombre". From the user´s selection, they can open up differing forms using command buttons that display filtered information about either members of "grupos", activities of "grupos", or objectives of "grupos".

The filter is working well EXCEPT for when the user selects a field on the listbox where there is no data entered yet. For example, one field in "grupos" may have records for objectives but no records for activities added yet. When the user tries to open the form based on the selected field with no records, it is completely blank.

I have created a form where a user can enter a new record for an activity, is there any way to open this form automatically if there is no record present as to add one...maybe using a conditional recordcount function to open the form if records for a certain field = 0?

I think I am a being a little confusing, so I will copy the code that is currently in place for the open event of the form based on the listbox query:


Private Sub EditarActividades_Click()
Dim varItem As Variant
Dim strNombre_Grupo As String
Dim strFilter As String

If SysCmd(acSysCmdGetObjectState, acForm, "ActividadesNoModificar") <> acObjStateOpen Then
DoCmd.OpenForm "ActividadesNoModificar"
End If

For Each varItem In Me.grupos.ItemsSelected
strNombre_Grupo = strNombre_Grupo & ",'" & Me.grupos.ItemData(varItem) _ & "'" Next varItem

If Len(strNombre_Grupo) = 0 Then
strNombre_Grupo = "Like '*'"
Else
strNombre_Grupo = Right(strNombre_Grupo, Len(strNombre_Grupo) - 1)
strNombre_Grupo = "IN(" & strNombre_Grupo & ")"
End If

strFilter = "[Nombre_Grupo] " & strNombre_Grupo

With Forms![ActividadesNoModificar]
.Filter = strFilter
.FilterOn = True
End With

End Sub
Nov 12 '08 #1
2 2043
Kevin Wilcox
68 New Member
Hi

Yes, you can certainly open another form or do whatever else you want based on the result of a recordcount, i.e. recordcount = 0.

Kevin
Nov 13 '08 #2
lhsiber
2 New Member
Thanks for the reply, but as I am new to access I am not quite sure of the syntax and where to place the IF condition in my code so that it opens only when there are no records. Could anyone show me the appropriate syntax and where to place it in the code?
Nov 13 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
6449
by: CSDunn | last post by:
Hello, I have a problem with field filtering between an Access 2000 Project form (the application is called CELDT), and the report that shows the results of the filter. Both the form and the...
10
5737
by: DataBard007 | last post by:
Hello Access Gurus: I use Win98SE and Access97. I just built a simple Access97 application which holds all contact information for my personal contacts, such as first name, last name, address,...
2
3628
by: Colleyville Alan | last post by:
I have a listbox that is populated with info and when the user selects categories of things from the list, it brings up detailed items from which to choose. I want to be able to put a filter on...
0
2277
by: Ray | last post by:
Folks, I have just created a simple procedure that does the following: Determines the width of the columns of a listbox. Places a button of the correct size above each column as the form opens....
1
3875
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
8
2406
by: daddydfsu via AccessMonster.com | last post by:
I am trying to create a ListBox based on a search from a TextBox. I have a TextBox where I will enter in a MemberAlias. I want to click on a Search Button and that will do a select from a...
1
4008
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
4
2528
by: Gilberto | last post by:
Hello, I have a couple of forms using the code to FIND AS YOU TYPE from Allen Browne (http://allenbrowne.com/AppFindAsUType.html). It worked PERFECTLY until yesterday when i splitted the db into...
1
1923
by: sheldonlg | last post by:
I have inherited code with a TDC control. In this file, there are two javascripts of interest. One of these is a function, filter(), which is inside <script language=javascript></script>. The...
0
7146
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7183
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6852
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5448
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.