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:myaccess
umber.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
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.
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?
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....
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:
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.
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.
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).
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?
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:
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!
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!
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.
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
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?
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)
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.
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.
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.
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
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.
I have a listbox that another subform on the same main pulls results from the column(0) id from (using text box that pulls the list record selected)
When you click once it (listbox) shows the records in the second form for the corresponding. When you double click it opens the record of the selected (listbox)
This works great in Runtime 2010 for all my 32bit staff and vista
however in 64bit win 8 with any runtime including 2013 64bit the database listbox works for a while, then slows and then stops opening the record on double click and when I say slows it slows to a crawl speed like it is looking up the query in the subform instead of just opening the record with the double click.
I was thinking mouse double click settings but they seem fine and as I said before it works fine for a while.
What i wish to do: list activities in a continuous form, and in one column display for each row a listbox which rowsource query is based on another column value from the same row.
I have to admit that the best thing for me would be to be able to create through vba a continuous form... is that possible?
I am new to database and hope this is a simple problem. I have a few thousand products each with their own code and description.
I would like to create a form that when I type in the code the description self populates in an adjoining box. I would like to enter at least fifteen codes and their descriptions per form. Have tried related tables using forms and sub forms with child/parent link but any editing of code changes the information back on the table. Tried parameter query but how can I get more than one code on a form at a time? Any suggestions greatly appreciated.:confused: