Clear Records From A Listbox

Oct 29, 2007

I have populated a list box with records using 3 columns. now I want to clear the list box
Me!Listproperty.Value = "" does not do it
what code should i use ?

Jabez

View Replies


ADVERTISEMENT

Clear A Listbox???

Feb 21, 2005

I'm using access 2003, and for some stupid reason they decided to remove the "clear" method from listboxes... In previous access version I could clear a listbox using "listbox.clear", but now I have no idea. Does anyone know a good way to clear listboxes in Access 2003.

View 4 Replies View Related

Clear MultiSelect Listbox

May 21, 2007

I have a multiSelect Listbox that has email recipients. I have a command button with Me.emaillist = Null, and after I click the command button the Listbox is still highlighted in black. What VBA command do I create to completely clear the multiSelect Listbox, including the highlighted selection?

losstww

View 1 Replies View Related

Forms :: Multi-Select Listbox Will Not Clear Selected Lines

Apr 7, 2013

I have a multi select listbox that I rebuild as I index thru some products in another listbox. This listbox then gives me the ingredients I can use. Works well, but the ghost selections in the listbox stay hilighted even after the rebuild.

I can select and de-select at will if there are actual items in the list box, but the ghosts remain.

Here is the code to clear the listbox

Dim _
ctlSource As Control, _
varSelected As Variant, _
intListCount As Integer
Set ctlSource = Forms.frm_select_UPC_LoinGrade!lstBox_ColdStorage
For intListCount = 0 To ctlSource.ListCount
ctlSource.Selected(intListCount) = False
Next intListCount
Forms.frm_select_UPC_LoinGrade.Refresh
Forms.frm_select_UPC_LoinGrade.Repaint

View 3 Replies View Related

Clear Out A Table To Add New Records

Jan 31, 2006

I have a transfertext macro that imports my text file into a table but the table already has data in it so it is not importing and losing all the records. What do i do to clear out the table before i import in.. Can i use another macro ???

View 1 Replies View Related

Clear All The Records In The Subform Of The Record In The Main Form

Jul 19, 2005

Hello,

I am trying to create a command button that clears all the records in the Sub form in the CURRENT RECORD OF THE MAIN FORM.
I know this sounds a little bit confusing, but I hope you understand!

The main form is: frmOrder2
The subform is: subfrmItemOrder

The fields in the subfrm that has to be cleared are:

Items (combobox)
UnitID (combobox)
K1 (txtbox)
K2 (txtbox)
K3 (txtbox)
CSB (txtbox)
DTSS (txtbox)
H (txtbox)
Remarks (txtbox)


The two forms are linked by the field OrderID.

Please help me!!
Thanks!
jenny

View 14 Replies View Related

Union Query - Create Additional Field / Clear Records

Jul 20, 2006

The code pasted below creates a union query for a set of tables (J000171, J000174, J000178 etc) and stores the results of the query in a table called temp.

The first piece of code queries the ‘status’ field of a table rjobs for those records with a ‘status’ field of “Live”. Another field within this rjobs table, ‘JobID’, happens to be the name of a table where additional information relating to that job record is held eg. J000178 All of the tables selected in the query on rjobs are then included in the union query.

The second piece of code stores this information in a table called temp

I would like to be able to do 2 things with this;

1.add an additional field to the union query which holds the JobID field value from rjobs (or alternatively the table name from which the data originates eg J000178 etc as that is the same as the JobID file din rjobs)

2.create an option to clear the info in the temp table. Currently additional info is appended, so whenever the query is refreshed new data is simply added to old data. I would like to be able to clear that data where possible.

The union query is run from the on click of a command button on a simple form. Perhaps an additional button could be used to clear the records from the table temp.

Any ideas greatly appreciated.

Here is the existing code …

Option Compare Database
Option Explicit


Private Sub Command0_Click()
Dim db As Database
Dim rsRjobs As Recordset
Dim rsRapps As Recordset
Dim LengthofUnionSQL As Long
Dim sql As String
Dim UnionSQL As String
Set db = CurrentDb
Set rsRjobs = db.OpenRecordset("Select * from rjobs where Status = 'Live'", dbOpenSnapshot)
Do While Not rsRjobs.EOF
UnionSQL = UnionSQL & "Select ObjectID, SearchNo, DateSearched, Consultant, from " & rsRjobs!jobID & " Union "
rsRjobs.MoveNext
Loop
'following two lines are to remove the trailing word Union from the string unionsql
LengthofUnionSQL = Len(UnionSQL)
UnionSQL = Mid(UnionSQL, 1, LengthofUnionSQL - 7)
' Now variable Unionsql will hold the value something like
' Select ObjectID, SearchNo, DateSearched, Consultant from J000145
' Union Select ObjectID, SearchNo, DateSearched, Consultant from J000146
' Union Select ObjectID, SearchNo, DateSearched, Consultant from J000147
MsgBox UnionSQL


Set db = CurrentDb
Dim rsUnionquery As Recordset
Dim rstemp As Recordset
Set rstemp = db.OpenRecordset("temp", dbOpenDynaset, dbSeeChanges)
Set rsUnionquery = db.OpenRecordset(UnionSQL)
Do While Not rsUnionquery.EOF
rstemp.AddNew
rstemp!ObjectID = rsUnionquery!ObjectID
rstemp!SearchNo = rsUnionquery!SearchNo
rstemp!DateSearched = rsUnionquery!DateSearched
rstemp!Consultant = rsUnionquery!Consultant
rstemp!jobID = rsUnionquery!jobID

rstemp.Update
rsUnionquery.MoveNext
Loop

End Sub

View 2 Replies View Related

Delete Records From A Listbox

Apr 14, 2005

I have a form with a listbox on it and I am trying to make a button that will delete the selected records from a table. The List box is filled from a query. Any help would be very appreciated.

Table to delete records from = tbllinkPersonel_Training
listbox = lstTraining_In

_______________________________________________
Private Sub cmdDelete_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim var As Variant
Set db = CurrentDb
Set rs = db.OpenRecordset("tbllinkPersonel_Training")

If IsNull(Me.cboTraining) Then
MsgBox "No Class selected...", vbExclamation
Exit Sub
End If

For Each var In Me.lstTraining_In.ItemsSelected
With rs
.Delete
End With
Next

MsgBox "Deleted Successfully...", vbInformation

rs.Close
db.Close

Set rs = Nothing
Set db = Nothing

Me.lstTraining_In.Requery
Me.lstpersonel.Requery
End Sub
____________________________________________

Thanks, Michael

View 7 Replies View Related

ListBox Shows All Records

Oct 26, 2005

I have a form with a subform which has a listbox on it which lists all the letters sent home to a student. However despite the subform being linked by admission Number the list box is showing all records and not just the ones associated with the student.

I know this is going to be really obvious but please can someone tell me what is wrong?

View 14 Replies View Related

Move Records On ListBox

Mar 29, 2006

Here's a tough one that has been driving me crazy! (Probably easy, but I don't want to admit it!)

I have a form with a listbox called "lst_exclist". The recordsource for this listbox is the following query:

SELECT tbl_collexcludereasons.priority, tbl_collexcludereasons.excname, IIf(tbl_collexcludereasons.enabled=-1,'Enabled','Disabled') AS enabled, tbl_collexcludereasons.priority FROM tbl_collexcludereasons ORDER BY IIf(tbl_collexcludereasons.enabled=-1,'Enabled','Disabled') DESC , tbl_collexcludereasons.priority;

Which basically gives me this with dummy data:
2 PIPELINE ENABLED
3 HELLO ENABLED
5 GOODBYE ENABLED
1 BAD DISABLED
4 GOOD DISABLED
6 LAST DISABLED

I had two command buttons, one up arrow and one down arrow. The up arrow is supposed to move the selected record on the listbox up by exchanging the next lesser priority number with itself. The down arrow does the same. The DISABLED records are supposed to be ignored on the move up and move down procedures, meaning only ENABLED records are allowed to exchange priority numbers, and thus move up or down on the list. I tried the following code:

Me!lst_exclisthidden = Me!lst_exclist

DoCmd.SetWarnings False

Dim startingnumber As Integer
Dim endingnumber As Integer
Dim nametochange As String
Dim getchangerst As DAO.Recordset

If IsNull(Me!lst_exclist.Column(0)) = True Then
MsgBox "Please choose an entry on the above list to move.", vbCritical, "Error"
Exit Sub
Else
End If

If Me!lst_exclist.Column(2) = "Disabled" Then
MsgBox "There is no need to move a disabled selection, please enable the selection to change it's priority.", vbCritical, "Error"
Exit Sub
Else
End If

startingnumber = Me!lst_exclist.Column(0)
nametochange = Me!lst_exclist.Column(1)

endingnumber = startingnumber + 1

If Me!lst_exclisthidden = acLast Then
MsgBox "You cannot move the bottom selection on the list down, please choose another one.", vbCritical, "Error"
Exit Sub
Else
End If

While DCount("*", "tbl_collexcludereasons", "Priority = " & endingnumber & " and Enabled = -1") = 0
endingnumber = endingnumber + 1
Wend

DoCmd.RunSQL "Update tbl_collexcludereasons set tbl_collexcludereasons.priority = tbl_collexcludereasons.priority - 1 " & _
"Where tbl_collexcludereasons.priority <= " & endingnumber & " and tbl_collexcludereasons.priority > " & startingnumber

DoCmd.RunSQL "Update tbl_collexcludereasons set tbl_collexcludereasons.priority = " & endingnumber & " " & _
"Where tbl_collexcludereasons.excname = '" & nametochange & "'"

Me.Refresh

Me!lst_exclist = endingnumber

Me!lst_exclisthidden = Null

DoCmd.SetWarnings True

But it seems to loop when it gets the the area it is checking for numbers because the highest records is disabled, so it's ignored. How can I make this work? Please help!

Thanks

Vassago

View 1 Replies View Related

Listbox Records On Report

Dec 23, 2004

what is the best approach to get my listbox's values on a report. i have a form that has this listbox (the values in listbox can always change.. because the user has filter options.. to tell the listbox what records to display). this report will be run off of the same form (as the listbox is on)... can someone point me into the right direction?..thanks!

View 3 Replies View Related

ListBox Search Records

Jan 7, 2005

Having an excruciatingly hard time seting up a txtBox and listBox to search records



ListBox, which contains an agency name should display all but filter out as user types in the textBox above. this listbox should allow a user to double-click to bring up record.



Will really appreciate the help! I have seen it being done on Access – and was wondering if anyone knows of a link or tip on setting this up!



ThankYou Friends!

View 1 Replies View Related

ListBox To Select Records... Please Help

Aug 5, 2005

Hello All...

I currently have a ListBox which I am using on a form as a "jump To..." record selector. It has to show 4 values to the users, and so far it has worked quite well. However, I recently added some queries to the footer of the form to help narrow down the data for searches, or if the user wants to see all open data of a certain topic. I'd like to have the ListBox "refresh" and only display the results of the query, but I cannot for the life of me figure out how to do it. The root of the problem seems to be that the initial SQL for the ListBox is selecting values from the under-lying table, and when the filter is applied, it simply doesn't care. When you click on entries that aren't in the filtered dataset, it doesn't error out or anything, and when you click ones that ARE in the filtered dataset, it does work properly... I'm close... How do I filter the listbox as well?

Thanks,

View 4 Replies View Related

Modules & VBA :: Using A Listbox For New Records?

Jun 11, 2013

I need the following code to take data from a form and input it into two tables linked by the item ProjectID. My Code is as follows:

Code:
Dim pDate As Date
Dim fid, jan As Integer
Dim leng As Double
Dim strSQL As String
Dim varItem As Variant
pDate = Date

[Code] ....

I take the items that I'm putting into DailyT to track the date, foreman, Job Number, and how long they spent on the job. I got the DailyT part figured out.

What I don't know how to do is use the items in the list box lstSel and put them into the table ProjectT so that each record in ProjectT has the ProjectID from DailyT and the ActivityID that comes from the items in the listbox.

I know I'll need a loop but I don't know how to get the autonumber ProjectID (or define it) from the entry that I made in DailyT to put into ProjectT.

View 3 Replies View Related

Listbox Doesn't Display All Records

Aug 5, 2005

I am using a SQL statement as the rowsource of a listbox. the expected result should be a list of 452 items which I verified by pasting the SQL statement into the Access query design and running the query directly. For some reason, in most cases, the listbox will only display 21 records. Other times it may display more than that (with the same SQL statement). What's really unusual is when I click on the form's "Find" button after the first set of 21 lines appears: it will then append more records to the list. Sometimes by doing this I can display all 452 records. The results seem to be somewhat random. I've tried adding delay loops, DoEvent statements, multiple requeries, repaint, etc. -- nothing I've tried seems to help. Any ideas?

View 3 Replies View Related

Deleting Multiple Records In Listbox...?

Jul 6, 2006

hey all,
I'm using this code on a command button to delete single entries in a listbox... and it works fine
Private Sub DeleteMovie_Click()
CurrentDb.Execute "Delete from " & _
"tblMovies " & _
"where Title = """ & Me.lstList & """", dbFailOnError

Me.Requery
Me.lstList.Requery
Me.lstList = ""
End Sub
However, I want to try to select and delete multiple items in the list box. So I changed the property to allow multiple selections and now the button doesn't do anything when I click it. Ideally, I'd like the button to provide a "are you sure (yes or no)" prompt. Anyone know how to get this working? thanks a bunch

View 6 Replies View Related

General :: Loop Through Listbox Records

Feb 15, 2014

I am looking to loop through all of the rows in a listbox. For each row in the listbox, I want to check if the last name in the Labor column is contained in any records in the Labor column of a recordset. If it is contained, add the column value to a variable to eventually be shown in another listbox. It seems that the loop is not working correctly and the EstHours is always 0 and the instr function doesn't seem to be working.

Code:
Sub ScheduledHours()
'on error goto errorhandler
Dim LastName As String
Dim FullName As Variant
Dim EstHours As Long

[Code] ......

View 3 Replies View Related

Modules & VBA :: Check That No Records Are Selected In A Listbox

Apr 28, 2014

I have button on my form that uses a selected record in a listbox (non multi-select) to run code that updates a table. The code itself works great so long as there is a record selected in the listbox. If no record is selected an error is thrown. I'd prefer the end user not to ever see that error. If the end user clicks the button and no records are selected, I'd like for nothing to happen at all. I've tried several variations of checking the listbox with an if / then statement to see if records are selected and if so to exit sub, but they all throw errors when no record is selected in the listbox.

Code:

If IsNull(Me!lstHeatTreatments) Then
Exit Sub
End If

[Code].....

View 2 Replies View Related

Modules & VBA :: Scroll Listbox To The Top - No Selected Records

Apr 23, 2014

I'm using the following code to clear selected records from a listbox after a button is pressed:

Code:

For i = 0 To lstProducts.ListCount - 1
lstProducts.Selected(i) = False
Next

The code works great except that it leaves the listbox scrolled all the way to the bottom. What is the best way to scroll back up to the top of the listbox without selecting another record?

View 3 Replies View Related

Forms :: Passing Records From A Listbox To A Table?

Sep 3, 2014

I have a form where I do a search and find the correct auditor in the listbox from the AuditorTable. This form is opened from a master form where I have the same fields in the table (ClientTable). What I need is that when I find the one, I double click it and the records from that auditor is passed to the client table.how to use Dlookup.

View 14 Replies View Related

Modules & VBA :: Using Records In Listbox To Add New Record To Table?

Mar 27, 2014

I'm using access 2010. I want to put some code behind a button that will allow the user to add selected products in a listbox to which ever operation is selected in a combobox by creating records for each product / operation combination in a third table:

tblProducts
tblOperations
tblOperationProductMM
- ProductID
- OperationID

I have a form with a combobox on top that allows the user to select the operation for which they want to add products. There is also a listbox that displays all records in tblProducts. The user can select one or more products and then the idea is that they can then press a button that will use the selected record IDs from the list box and the record ID from the combo box to create new records in the many to many table.

View 5 Replies View Related

How Make Query Criteria Come From Selected Records On A Listbox

Mar 15, 2008

I have a form which contains a listbox. It is a multi-select listbox. And I have a button on the form which runs a report. But I want the report to only show the selected records from the listbox. The report gets its records from an underlying query. But how do I make the selected records on the listbox become the query criteria?

View 4 Replies View Related

Display Prevoius Selections In Listbox When Editing Records

Jun 12, 2006

I have two unbound multi-select listboxes that saves selection to their respective table. It works just dandy. However, whenever I go back to the same record, the listbox is blank and apparently I have to instruct it to "retrieve" the previous selection from the table using the PK as criteria.This is far as I can get, though this code causes several errors and I'm not sure what I need to put in as an array for "For Each" statement. If anyone can guide me how to retrieve the old selection from the table and displaying on listbox, that would be great.If IsNull(DLookup("[ClientID]", "[tblClientAccommodations]", "[ClientID]=" & Me.ClientID)) = False Then Dim RecCount As Integer Dim Index As Variant RecCount = DCount("[ClientID]", "[tblClientAccommodations]", "[ClientID]=" & Me.ClientID) For Each Index In Me.lstReasAcc Me.lstReasAcc.Selected = (DLookup("CommunicationID", "[tblClientAccommodations]", "[ClientID]=" & Me.ClientID)) Next iThanks in advance.

View 3 Replies View Related

Show Certain Records (eg: Unpaid Transactions) As A Different Colour In A Listbox

Nov 30, 2006

i think this post may benefit others because to me it seems like a good idea,

a listbox displays 2 fields from your database

job table
id (autonumber primary key)
pay (text)

here are 5 records,
1,paid
2,paid
3,paid
4,unpaid
5,unpaid

if you make a form with a listbox showin these records..

is there a way to make the unpaid records appear as red?

View 9 Replies View Related

Forms :: How To Display Records On A Form Based On Listbox

Jun 5, 2014

I designed a simple form that has a listbox and a subform. I am using Northwind database for testing.

I would like to be able to display on a subform only records based on a value of a list box.

I created a listbox using a wizard and selected an option 'find a record on my form based on the value I selected in my list box'. This kind of works but it does not display all records matching criteria.

Attached print screen 1 shows my table and there are six records for 'Las Vegas' but my sub-form displays only three for Karen Toh (print screen 2) and all records for John Edwards are missing. I am not really sure how to fix this problem.

Ideally I would like to take this a step further and do another list box with Last Name and then filter data even further down so for example if I select Last Vegas and Edwards then the form would show me only matching records.

View 3 Replies View Related

General :: Combobox Filtering Listbox To Only Show Same Records

Apr 4, 2013

Ok I have a list box (CounselorInitials) and a listbox (AssignedToYou)

The list box has 6 columns and is using a query (AssignedToMe). The important one is the 6th one (Counselor). All working off a table called DityLog.

I want to select initials in the combo box and then it will filter the listbox and only show records that are the same.

So if I select initials MC from the combo box I want the Listbox to show all records that have the initals with MC.

View 1 Replies View Related







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