Related Topics

Changing Listbox "row Source" Property Using Vba

Handling multicolumn listbox row source
I have a multicolumn listbox, and all the fields in the row source are from one table, but one of them is "assignType', a numeric field. It can be 1, 2 or 3. The thing is, I need the listbox to display text based on this numeric value, i.e. 1=assignment, 2=decision, 3=text. In other places I just put invisible textbox with control source set to assignType, wrote the text values in row source and then defined other comboboxes row source as [assignType].[column](1), but how do I solve this in listbox


Add items from query to listbox with vba
I know this sounds simple enough, but there is a little twist. Usually, I would just set the row source to the query and we are good to go. However, in this case, I want the user to be able to double-click to remove the selected item from the listbox. It will eventually get transferred to a different listbox.

In order to do this, the listbox row source type has to be value list, which doesn't allow me to put in an SQL statement to grab the query info.


Listbox multiselect status
I would like to programmatically change the ListBox.Multiselect property setting. Part of the time I want it set to "Extended" to open multiple documents. Other times I need the property set to "none".

The following line causes error that property is being used improperly:

Me.LstListBox.MultiSelect = 0 'none

I tried both setting the focus off the listbox and on the listbox and neither option seems to resolve the issue.


Listbox multiselect status
I would like to programmatically change the ListBox.Multiselect property setting. Part of the time I want it set to "Extended" to open multiple documents. Other times I need the property set to "none".

The following line causes error that property is being used improperly:
Me.LstListBox.MultiSelect = 0 'none

I tried both setting the focus off the listbox and on the listbox and neither option seems to resolve the issue.


Listbox problem
I'm working in Access 2003 from a query. I have a form with 2 comboboxes and a listbox. The comboboxes are to select Extension and Date. The listbox gives activities per extension, per day, e.g.

"Sign on", Sign off", "Idle" etc. The SQL statement I'm using for the listbox row source is as follows:

It runs this way, but using input boxes for "Extension" and "Date". I"m using those as placeholders because I want the values of te two comboboxes there instead, so users can select Extension and Date instead of inputting them.

The comboboxes are cboExtension and cboDate. What do I need to do in order to get the listbox connected to the two comboboxes?


Access 2000 How To's: Access Tree View and List Box Row Source
How to Load a Category Tree and Listbox RowSource Type "Field Value" Property. In this Access 2000 article, I will show you how to create a category tree and load it into a listbox. I will demonstrate the steps to create a static value list and associate it with a listbox. The algorithm can be easily ported to a treeview control or to HTML for an active server page.


How To Access From VBA A Tables Row Lookup Row Source
I created a table field with a Lookup Row Source Property Type = Value List
and a hand-coded list of values. The user can right click this field in a form and add additional values to the hand-coded Row Source (I.e. Joe, Mary, John, and then they add Mark). How can I access the Row Source in VBA because I need to use it in a drop-down UNBOUND Combo Box. I searched everywhere including the Object Browser.


How Do I load a ComboBox at Runtime?
I have set the 'Row Source Type' property of a ComboBox to Table/Query. I have set the 'Row Source' property to qryFullName ( "SELECT tblAdvocates.Forename+' '+tblAdvocates.Surname AS FullName
FROM tblAdvocates;") but it loads nothing in the ComboBox ? I will check the SQL syntax, but whether it's through creating a recordset in a VBA procedure, and looping through to 'AddItems' to the list, storing the first and surname in a string, or setting a subset to set the RowSource using a query.

I wish to concatenate these 2 fields, to create a list for said ComboBox. it used to be so much easier in earlier versions of VBA!


need to use vba to change a property to table data
I am currently working a a Junior IT and am new to Access and databases in general. I have been tasked at finding a way to integrate an activex object into our database.

What I am trying to do is have it so that when we load a report the object is autmatically populated with the relevant data from a table. Unforunetly this particular control does not have a "Control Source" property, otherwise I would just modify that. I have successfully made it so that I can change the property of the object in question using vba. What I would like to know is if there is any way I can have vba insert table data, much like I would do using "control source" (if it were available


unbound listbox. how do i make the current record selected
I have a listbox that displays the name of all the records, as I use the navigation buttons to go through different records my listbox does not update what it has selected.

My listbox is unbound and here are some things you might want to know:

Row Source:
SELECT InspectionsDI.ID, InspectionsDI.[Manhole Number] FROM [InspectionsDI Query];

Private Sub lstDI_AfterUpdate()
DoCmd.GoToRecord acDataForm, "DropInletForm", acGoTo, lstDI.ListIndex | 1 End Sub


Adding criteria to RowSource
I have a listbox thats row source is set via dlookup. its copying SQL string from another table.

lstResults.RowSource = DLookup("[SQL_STRING]", "RebisView", "View_Name =" & Chr(34) & selview & Chr(34))

I need to add a creiteria to this row source. Problem is I cannot add it to the original SQL string as it is used in other parts of our application and can't be modified.

The criteria I would like to add is stored in a variable.

How can I add this criteria to the query after the query is set into the rowsource of the listbox?


Action after a listbox updates
I have a listbox on a form which displays data based on the value of a textbox. I requery the listbox every second or so using the timer event on the form. What I want to accomplish is that whenever the listbox changes, i.e. a new row is added to the list, a subsequent action (in my case, a beep) occurs.

I tried the afterupdate property of the listbox but that doesnt seem to work. The listbox is unbound.


Action after a listbox updates
I have a listbox on a form which displays data based on the value of a textbox. I requery the listbox every second or so using the timer event on the form. What I want to accomplish is that whenever the listbox changes, I.e.

a new row is added to the list, a subsequent action (in my case, a beep) occurs.

I tried the afterupdate property of the listbox but that doesn't seem to work. The listbox is unbound.


How do i open a form and hide a field?
Currently I need to hide a listbox whenever I open a form. I think the best way to do this is to turn off the visible property.

This is my code:

Private Sub ShowCommitRecord_Click()

DoCmd.OpenForm "AddCommitmentDetail", , , "CommitmentID=" & Me.ListShowCommit.Column(3), , , "Edit"
DoCmd.Close acForm, "SelectEditCommitment"

End Sub
This is from a form where I select a record from a listbox and then open a form based on the selected record using a button.

I dont know what is the visible syntax so could anyone tell me how to turn off the visible property of a control using vba when opening the form


Listbox row source and record locking?
I'm setting up my first true multi user database and I have a question on record locking.

If I set a list box row source type to "table/query" and specify a select query for it, does Access lock those records? In the past I have always used "value/list" and loaded the records with code but it would be much easier to use ""table/query" if it does not lock the records.


Calling To a Combo Box By Row Source, Not Value List
s I encouraged with the problem.
I have a combo box and there are values in my native Language "Georgian" from VBA I can't coll, because VBA can't recognize my language and cant write showing only "?" this.
Then I decided to call not the value inside the combo box, but to call by row source of the combo box

I'm Trying something like that:

If Me.[Combo Box Name]= row source (2) Then
Me.[LOCKED TEXT BOX TO BE ENABLED].Enabled = False
Else
Me.[LOCKED TEXT BOX TO BE ENABLED].Enabled = True

End If
By value list it's working perfectly if the values are written in Latin, I just need to call to a row source

Can you explain how to. or correct my


Using Access VBA to edit Excel document
So I have an Excel macro that has the following:

Sub Test()
Rows(2).EntireRow.Insert
[D2] = "ABC"
End Sub

which adds a new row (at row 2) and inserts "ABC" in cell D2. However, I need some way to embed this code behind an Access button in VBA. I understand that you can call an Excel Macro from Access, but the Excel document is changing often and will not always have the macro attached.

So my question is: How can I open the Excel document, insert a Row at line 2 and type "ABC" in cell D2, and save and close the Excel document? ALL from Access VBA,

My .xls file is named "importtest.xls" and the sheet where I want to do this editing is "Sheet1"


Getting listBox value after selecting a new row
I have a multi select listbox in which I am trying to get the value of the listbox after I select or deselect a value. Normally, I would think that after you select or deselect a row in a listbox, the value would change to that row, but it doesn't seem to be doing that. Am I wrong in thinking that?

If I am, I need to know how you can get the value of the listbox to change to the row that was just selected or deselected, that way I can do different things with the rest of the form based on that. If I have to use the index of the listbox, I am alright with that. I just need to know how to get the value to change


Another Permutation of Invisible Form Records
First, I have a .accdb 2007 form that.

1) Has a query SELECT/FROM record source and a "Dynaset (Inconsistent updates) recordset type.
2) Has controls that are bound to two tables. The two tables have primary keys of the same name and data type.
3) Has one control that is a listbox bound to a query that gets its data from my detail/secondary table.
4) Has no "bound" errors in any control.

My detail table only has two fields. One is a date, which is bound to a date control on the form. I need to repeat one of the fields in this detail table in my master table in order to associate an employee with a code (I know this is poor database structure, but in this case, it needs to be done somehow).

I repeated a field ("code") and made it the primary key in both tables to do this.

In order to populate my master table with the "code" value from my listbox (bound to my detail table), I created an non-enabled form control that issourced to the "code" field in the master table and populates on a lost focus event of the listbox.

The listbox based on the query populates fine.

Secondly, here is my question: Is there anything in the above description that would prevent me from seeing the 15 records in my master table?

There's records in every primary key record in the master and detail tables. The Form "Data Entry" property is set to "No". The Form Detail "Visible" property is set to "Yes". For flexibility; the "Allow Additions" property is set to "Yes".

I know I can't simply change the source control of the form off from a query because it references multiple tables. There seems to be no end to the permutations Microsoft can come up with that cause this problem. Shoddy products - just like Steve Jobs said.


How to display additional info from a listbox to another listbox
I have an access form named frmManagers and within the form I have two Listboxes namely lstManagers and lstStaff. On my lstManagers listbox, my Row Source are EmpID, LName, FName, Manager (tblEmployee) and on my lstStaff listbox the Row source are EmpID, LName, FName and Manager (tblEmplyee). I have 3 unbound textboxes and 4 command buttons (New, Save , Update and Delete).
If I select a manager in my lstManagers, the infomations are displayed on the 3 unbound texbox wherein I could perform Update or Delete for that record.

My problems are:
Problem 1. to display the employee or employees who are directly reporting to this manager (based on the LName of the Manager in lstManagers) and display the results in my lstStaff listbox.

Problem 2. based from the result in Problem 1, be able to change the Manager's LName in lstStaff in one sweep instead of changing every employee record.