Cascading Listboxes Not Updating Correctly

Nov 14, 2013

I am working on a very simple DB. The two fields in question are Country and City, both as text. The idea is that the user can choose one country from a single-selection ListBox and after selecting one country the Cities multi-selection ListBox gets populated through the following SQL search. The Table Country_City contains two rows with countries and cities, nothing complicated.

Code:
Private Sub BU_AfterUpdate()
'I deselect all the selected items
'*** WHY THE IS THIS NOT WORKING ???!!! ***
For i = 0 To AppliesTo.ListCount - 1
AppliesTo.Selected(i) = False
Next i
City.RowSource = "SELECT Country_City.City " & _
"FROM Country_City " & _
"WHERE Country_City.Country = '" & ListBoxCountry.Value & "';"

After I click/select a country on the first ListBox, the second does get populated correctly. The problem I am having is if the user changes the country, then the previously selected city/cities still stay selected. I tried to reverse that by deselecting all the cities each time I change the country, but the for-next loop does not seem to be doing the job. The funny thing is that if I paste those three lines on a buttom and click it right before selecting another country, it does work.

Example:
1) I select "France" on the first ListBox.
2) I select "Paris" and "Lyon" on the second ListBox.
3) Now I select "Germany" in the first ListBox.
4) The second ListBox gets filled by all the cities in Germany, but the ones I selected before (Lyon and Paris) appear on it too, selected.

I want to reset the selection on the second ListBox in case the user selects another country on the first ListBox.

Some information on the fields:
Country: Display Control=ListBox, Row Source Type=Value List, Row Source="France", "Germany"
City: Display Control=ListBox, Row Source=Table/Query, Row Source=(empty, updates with AfterUpdate event on Country ListBox)

View Replies


ADVERTISEMENT

Forms Updating Tables Correctly

Feb 8, 2006

Hello all. Hope I describe my problem correctly. :D

I have a near complete database with forms linking to tables. Tables have relationships with keys set to ref. integrity/cascade records.

Here is the problem -

My forms are meant for people to input data into these tables. However, I do not want them to change those keys.

Problem 1) If I set primary/foreign keys to "autonumber" I cannot get the relationships to recognize ref. integrity and the records will not cascade, and will not update.

Problem 2) If I set primary/foreign keys to "double integer" then if someone enters a new record into the forms, it is recorded as "zero" when it should be updating in numerical order (I have 479 records in the database, so the next new record should be 480).

Problem 3) If I change it any other way - from double integer or auto number, the tables do not update at all, or do not update correctly.

What is going on here? I thought creating forms was a fairly simple task - create the form, it is related to the table, update the form, it updates the table. I mean, duh. :confused:

Thanks anyone for your help, because Microsoft's site sux.

View 1 Replies View Related

Forms :: Continuous Form Not Updating Tables Correctly

Feb 27, 2015

I have a continuous form that is using a select query to populate all of the bound controls. The drop downs and text boxes are displaying the values from the correct places. But, the form is not updating in the places I expected.

The select query that is being used to populate, combines information from 3 tables.'TimeEntries' table (the one that I want records to be updated in). This holds employee ID, and numeric values for Project Name and Project Task.

'ProjectInfo' table (nothing should be updated here). This table holds other details about the project (ex. Project Name) that is used to populate a combo box.
'ProjectTasks' table (nothing should be updated here either). This table holds details about project task (ex. Task Description) that is used to populate a combo box.

The issue I am having is that when records are updated on the form, they are adding records to all 3 tables that are a part of the query, instead of just updating the time entries table.

Record Source (form) = Select Query "EmployeeTimeEntry"

View 14 Replies View Related

Forms :: Subform Not Updating Correctly To Show Corresponding Records

Aug 26, 2014

I have been having issues with a subform on the attached database - for some reason it is not always updating to show corresponding records.

What I am planning, this is effectively going to be an interactive learning portal which can test users as well. There will be learning material (not yet included) and a bank of questions with corresponding multiple-choice answers, only one of which is correct. Each time the main form is loaded (Cat1MainForm) it randomly selects and orders questions, then, via a sub-form, returns three potential answers. There will then be radio buttons with which the users can answer appropriately.

If you load up Cat1MainForm and scroll through various questions you will see that sometimes the answers appear, other times not. Sometimes on one record the answers are there, you navigate away and back, and they have disappeared, and vice-versa.

View 4 Replies View Related

Forms :: Updating Table From Cascading Combo Box(s) Fox?

Mar 25, 2013

updating my table when I use cascading combo boxes in my form.What is happening is that my table is being populated by the xxxxID column vice from the xxxxName column that is being used from that specific table.

here is my visual basic code that I am using to determine what the subsequent combo box will display.

Option Compare Database
Option Explicit
Private Sub cboPlanktonID_AfterUpdate()
' Set the Family combo box to be limited by the selected Plankton Type
Me.cboFamilyID.RowSource = "SELECT tblFamily.FamilyID, tblFamily.FamilyName FROM tblFamily " & _
" WHERE OrderID = " & Nz(Me.cboPlanktonID) & _
" ORDER BY FamilyName"

[code]...

Example of the Combo box Row Source is: SELECT [tblWaterbody].[WaterbodyID], [tblWaterbody].[WaterbodyName] FROM tblWaterbody;

My Control Source is PlanktonAnalysis.WaterbodyName

When I fill in the form with the data, The Waterbody name is visable for selection (example: I see "Lake Lillinonah" in the cascading combo box, But when I save the record in the PlanktonAnalysis Table I get a number in the WaterbodyName column vice the name of the waterbody

PlanktonAnalysisIDWaterbodyName172
311411511677118397104113
tblWaterbodyWaterbodyIDWaterbodyName2Ashland Pond3Bantam Lake4Crystal Lake5Gardner Lake6Hungerford Park Pond7Lake Lillinonah8Lower Bolton Lake9Middle Bolton Lake10Pocotopaug Lake11West Thompson Reservoir

View 4 Replies View Related

ListBoxes Again

Mar 5, 2008

Hi,

i am looking for advice on listboxes. i have various books which all happily state everything exept how to use them!!

1st advice-

i need to know how to create an SQL statement on the listbox so it shows filtered dsata from a query. i am trying to filter by date so the list box could show multiple items carried out on the same date. is it:
SELECT Query.Field From Query Where Field

2nd advice-

a listbox shows data based on a query showing payments. i click on the payment in the listbox and a form opens with the specific data showing.
i have looked around but cannot find much on them.

help would be gratefully received as im currently stuck.


thanks,

NS

View 4 Replies View Related

Dynamic Listboxes

Jul 17, 2005

Hello,

I have two tables: Categories and Subcategories.

Categories contains one field: CategoryName
Subcategories contains two fields: ParentCategoryName and SubcategoryName.

In a third talbe I want to select a category from a listbox, then have the subcategory listbox update automatically with the possiblities. Is this possible?

Thanks.

View 1 Replies View Related

Linking 2 Listboxes

Sep 1, 2007

Maybe somebody can help me with this... in my form I have two listboxes, first one to select the name of the client and the second one to select the contact person of the client... both are linked to a seperate table...

first listbox works fine, only the second one gives me troubles... in the source query I link the ClientID to the ID of the first listbox with...

Forms![PRODUCTIONS]![ClientID]

when I run the form, I get all the time a message window on my screen with the text Forms![PRODUCTIONS]![ClientID] and asking a value for it... I think that I do something wrong with getting the ID from the first listbox....

can somebody help me with this what to do ?

View 2 Replies View Related

Populating Listboxes

Feb 11, 2005

Hi,

Trying to populate a listbox using a .txt file created used WORD. This is the code i'm using:

Private Sub cmdDisplayFile_Click()
On Error GoTo text_open_error
Dim sTemp As String
Open "m:myaccessumber.txt" For Input As #1
Do While Not EOF(1)
MsgBox ("in loop")
Line Input #1, sTemp
lstShowTextFile.AddItem sTemp
Loop
Close #1

I'm getting nothing in the ListBox. Any hints would be much appreciated.
text_open_exit:
Exit Sub

text_open_error:
MsgBox Err.Description
Resume text_open_exit

View 2 Replies View Related

Hi! I Need Help With Comboboxes, Listboxes...

Dec 5, 2006

I have a form with many combo and list boxes, but i don't know how to find a relation between them. I want to select a name of a product that is in a combobox and then a list or text box will show its description.... Please help me because I will burn out sooner or later :eek:
KD:confused:

View 12 Replies View Related

Issue About Listboxes!

Oct 27, 2005

Hi
I have an Access form. I have a listbox that has the value pulled from a query. I also have a button on the form. When i click the button, the value from this listbox should be appended to a table. So I am trying to do this by referencing this listbox value as Forms!subform!listbox.value . This is storing the value of null. any idea of how to capture the value that is stored in a listbox.

Thanks
Neelima.

View 3 Replies View Related

Text Align ListBoxes

Jul 20, 2005

Is it possible to align text inside a multi column list box.
For example, currency field is always aligned to the left
where it should be right aligned.

Kappler

View 1 Replies View Related

Viewing Listboxes In A Report

Nov 19, 2005

Good Morning all,

On a Form I have a series of Listboxes, each drills down to a final piece of information. The Listboxes store a number_id which displays along with other information In this case the number_id is associated to a TEXT description. When I send the Listbox info to the Report it displays the info but the text doesn't wrap and it gets cut off. There is no "can grow" option on a list box.

So I need to create a Text Box in the Report but when I refrence the listbox in the control source only the number_id shows up. I need to see the associated text (field).

Any help would be great!

Thanks,

Phil "bones"

View 2 Replies View Related

Multiple Multiselect Listboxes

Feb 18, 2006

Hi, my problems are numerous!
I have a form with a number of multiselect listboxes. Their sources are individual tables such as YEARS, PARISHES, CLIENTS. The underlying data is stored in a separate table. I want users to be able to select none, one or some values from each listbox and run a report.
As simple listboxes with one selection permitted this worked fine. I know that my problem is in concantenating the values.

I have tried attaching some code to the OnClick function of a cmd button on the form. I found this code referred to a number of times here and have tried to adapt it but no luck. I have now reduced my form to one listbox to test stuff out- this is the code-

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set frm = Form!testform
Set ctl = frm!lboparish
strSQL = "Select * from StJamesAgric where [Parish]="
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR [Parish]="
Next varItem

'Trim the end of strSQL
strSQL=left$(strSQL,len(strSQL)-300)

The first error I get is "can't find field 'testform'"

My form is called testform
The listbox is called lboparish
The table with all the data is called StJamesAgric

What am I doing wrong???? And also, if this code EVER works, do I need to repeat it for each listbox or do I insert refernces to each list box within just one subcommand?

Any help greatly appreciated.

Stella

View 5 Replies View Related

Three Listboxes From Same Table Issue

Jun 14, 2006

hi guys, i was wondering if you can help me. I have a data entry form in which the user has three listboxes from an existing table (only one table for the three listboxes). however if the user selects the same item from listbox1 in listbox2 or listbox3, i want him to get an error message and don't let that happen. how can i do this? vba code?:confused:

this is my form:

Please select your three items of choice.

1st choice 2ndchoice 3rdchoice
listbox1 listbox2 listbox3


listbox1.value cannot equal listbox2.value and cannot equal listbox3.value.

View 5 Replies View Related

Scroll Bars In Listboxes

Jan 7, 2005

In the forms that I have made, none of the listboxes ever scroll with the mouse scroll wheel. I have tried to click into the listbox first to ascertain that the focus is in the listbox but nothing works. the only way to scroll is to manually drag the scroll bar tab.
I want to find out how i can make my scrolling work. I guess that there must be a global setting somewhere to switch it on or off... Any insight into this will be highly appreciated!

View 1 Replies View Related

Listboxes In Access For Beginners

Apr 10, 2006

I'm not a programmer by any stretch of the imagination. I'm having an issue I could use a little pro help with.

I have a listbox called "ListDIV" on a form called "fRptCriteria". I am trying to have a query called "qOpenOrds" look to the listbox for some parameters. The field on the query is called "DVNO2Y". The form also contains serveral Calendar Controls "SDate" and "EDate" that the query is looking at too.

In the past, I've had no difficulty referencing a Combo box, but the is listbox issue is driving me nuts!

Thanks in advance.....

View 5 Replies View Related

Search Form With Cbo And Listboxes

Mar 28, 2007

Hello,

I would like to create a search form with four combo and a listbox which would display the result of the combo.

All combos get data from Table1.

I would like to add:
cboSSN
CBOLNAME
CBOFNAME
CBODOB

When users will select a SSN, then CBOLNAME will return all records showing a the same Last Name with data SSN.

If users will select cboLNAME, then CBOFNAME will return all first names of the records with that specific Last name.

Is there a way I can do this or same example? Thanks.

View 1 Replies View Related

Dependent Listboxes With Criteria

Jan 11, 2015

I have a form that has two listboxes. The first list box is named "lstType", which pulls in information from a table tblType. The second or dependent listbox, named lstSName, is then filtered and only shows the SName that match the type. This is pulled in from a table "tblSName." Using the form filtering on the query "[Forms]![frmqryTask]![lstType]"

This portion actually works perfectly and filter my form as I wanted it too (at least originally). However, I realized a few days ago that the when clients or the SName does not have any active projects my company will be working on for them, we don't want don't need to see their name on the forms listbox called "lstSNameand", so we want change a status from "Active" to "Inactive". I've already added this status in as well.

What I'd like to have happen is that when using the dependent listbox, the lstSName will only show those with the "Active" status. I've tried adding the status = active onto the query, however I get a error message saying the query is too complex to run, which I'm guessing has something to do with the "[Forms]![frmqryTask]![lstType]" on the query.

View 9 Replies View Related

Forms :: Move Selected Between Two Listboxes?

Dec 16, 2013

Move Selected Items Between Listbox1 (listEmp) and listbox2 (listAllocated). the items moved from listEmp must be removed from listEmp when moved to list allocated and vice versa.

Overview:

listEmp is my first listbox and currently has the query in it's rowsource
SELECT e.* FROM qryEmp AS e;
it has 7 columns but only 6 are showing (Column 1 is hidden)
and it is currently bound to 1

listAllocated has only 4 columns (can be changed) i only need the first 4 columns from the first list.
currently it has no row source and the row source type is set to Value
it is also bound to 1

I did find some code that does not do what I need but is closer than anything that I have found so far. It seems like it is copying the Selected Items from Column 1 and pasting it in the second listbox. but it is pasting them all in a row and not in individual columns below is the code. I will post a screen shot in 2 posts time.

Code:
Private Sub cmdCopyItem_Click()
CopySelected Me
End Sub

[Code].....

View 7 Replies View Related

Modules & VBA :: Using Listboxes To Organize Records

Jun 27, 2014

I have a form with 2 listboxes: 1 to show the name of the products having a code "v" (recordsource query), 1 to show the name of the products having a code "a".

2 arrowed buttons (left-right) would make a product "jump" from one to the other.

The way I wanted to do this is, when the appropriate button is clicked, the actual product code is changed, then the listboxes refreshed, so that it looks that the product jumped listboxes (when the code changes and the listboxes refreshed/requeried, it will disappear in one and appear in the other, because of the recordsource queries).

I want to do it this way, because it is imperative that the code gets changed!

But how to get the record of the selected product "out" of the listbox. When I select a product and check e.g. the ".value" of the listbox, it is "null"!?

So how to "get" the record corresponding with the selected item in a listbox in VBA?

View 7 Replies View Related

Combining Data From Multiple Listboxes?

Oct 4, 2012

I have created a DB who's sole purpose is to track employee availability and job positions available (a poor man's version of a scheduling database, if you will). I have 2 listboxes on one form. Listbox A shows all the employees available for work, and Listbox B shows the available work positions that require an employee. I am trying to create a functionality behind a button that will allow me to highlight one row in Listbox A and one row in Listbox B to combine the information in a seperate table (still not created) and refresh each Listbox to remove the entries. Similarly, I would also have to create functionality behind another button to undo the above, if needed.

View 1 Replies View Related

Need Help With Allowing Duplicate Selection For Transferring Listboxes

Jul 1, 2006

I found this sample (http://home.earthlink.net/~mgf00/SelectDemo.zip) which allows you to move your selections from one listbox to another with four buttons (<<, <, > and >>) which is just perfect.

Well, almost, actually.

This is already set up to protect against duplicates and that's a good thing. However in my case, my uppers want me to allow duplicates. The code is beyond my ability and my attempts only caused more problems.

The code requires a unique index be generated when the selection is moved between the listbox. Duplicating the index will cause error, and my attempt to circumvent that has either failed totally or is inconsistent (e.g. works if it comes up with a unique value, but will fail if it happens to duplicate a key).

Can anyone show me how I can modify the code to allow for duplicates? The selections then will be looped into a many side table.

View 5 Replies View Related

Forms :: Saving Selection From Listboxes To A Query

Aug 20, 2014

I am new to Access and I have get to where the users can make selections in the listboxes, but then I need to save the selection in a query or table to save thier changes.

View 1 Replies View Related

Modules & VBA :: Generate Dynamic Report From Listboxes?

Jun 6, 2013

Is it possible to generate a report from 2 listboxes?

I have attached a pic of what I am trying to accomplish. I am wanting to have a report open with only the criteria that a user selects from the listboxes.

listbox 1: User selects a case number(s)

listbox 2: User selects the fields they would like in the report

So, if the user selects:

Case number: 13-001

Then selects fields:

Allegation
Incident date
Focus_Last name

This report would be:

Code:
Case Number Allegation Incident Date Focus_Last Name
13-001 DUI 06/01/2013 Doe

View 5 Replies View Related

Forms :: Move Selected Items To And From Listboxes?

Dec 11, 2013

I have 2 Listboxes the first list is based on a query I need to select items from this box or part of each item and move to another listbox. the items in the second listbox will be used in a report. I have previously posted on another forum with no real luck fyi. the query is put straight in the RowSource.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved