Taking Multiselected Items From Listbox And Adding To Bookmark Location In Word

Feb 1, 2013

I understand how to pass text boxes to bookmarked locations in Word, but when it comes to combo boxes, list boxes, or option buttons, I am lost. So, my problem this time is the following:

I have an access user form that is asking the user to input data and make selections. Once entered I am trying to get everything to export directly to respective bookmarked locations in a Word Report. I have my text boxes working and I have the combo box now working. The issue I am experiencing is with the user making multiple selections from a list box and I am not really sure how to get that to export to the word document.

Here is what I have:

Code:
Dim strNames As String
Dim ctl As Control
Dim varItem as Variant
'ensure the user has made a selection from the testers name text box
If Me.testersNamesText.ItemsSelected.Count = 0 Then
MsgBox "You must select at least 1 Capability Testers Name"

[Code] ....

I am very new to trying to code with the Visual Basic side of things, I know this is probably the best method to do this but the issue that I am experiencing is receiving a Null error for the line with

.Selection.Text = (CStr(Forms!WebBasedIFV!testersNamesText))

And when I attempt to pass the strNames in place of the testersNamesText I receive that the user form can't find the field "strNames" referred to in my expression.

View Replies


ADVERTISEMENT

Combo Bound Column To Word Bookmark Conflict

Jul 6, 2005

Ok....Just when you think it's all running smoothly.... :(
I have a combo box, MDLastName, with a column count of 9, with column 2 displaying and all others hidden. The selection made with this combo populates 7 corresponding fields (first name, address, etc). It's working perfectly.

The first problem I encountered was with identical last names, but different corresponding data. When I selected Jones, for example, it would populate the first Dr. Jones and his info, listed in the table. However, if I selected the second Dr. Jones in the combo list, it was still populating only the first Dr. Jones' info. I resolved this by binding the fist column (ID, aka primary key), but still hiding all colums but column 2. First problem fixed..

Next, I have a Word Template document bookmarked to receive data from the form, frmDenial. I have all the coding working fine and dandy to insert the data from the fields on the form, save, and print. However, instead of inserting the text from the MDLastName, it is inserting the primary key (because it is the bound column in the combo box). Now, because of the first problem discussed above, I cannot change the bound column to column 2 (containing the data I need in the Word Template). How can I get the right info to appear in my template with the bookmarks?

View 1 Replies View Related

Move Items From Listbox To Other Listbox

Jul 16, 2006

Hello everybody,

Hopefully somebody can help me on this one. I searched the whole internet and access forums, but I didn't find the exact solution for my problem.

I've got a table with students, a table attendance, where I now only save the students who are absent, but I would like to save also the students who are PRESENT (at the same time).
I've got a combobox where I filter the Class, which then updates a listbox with the students from that class. What I do now is select the students from the listbox and then press a save button and it saves the records to the table absence with STATUS: ABSENT.

I would like to save the NON selected students also in that table, but with PRESENT in the column STATUS.

I thought of making another listbox next to it, where after selecting the absent students, they wil apear and disappear in the PRESENT table so I can store all the information.
But the only problem is that I can find this solution when the listbox is populated by a list of values instead by a table or query. And the other solution is to store the temporary data into 2 different tables, but that's not working for me because it's a multi user database and everything will be messed up.

Hope that someone can help me, I will be very happy.

View 4 Replies View Related

Accessing A File Location In Listbox Column

Jan 23, 2006

i have a url file location to a pdf file on the 3rd column of a listbox.

is there anyway of opening the file from a button, refering to the the highlighted record row 3rd column pdf file location

i know that me.lstBox.column(2) gets me to the column but not the code to open the pdf file for the highlighted record

any help would be appreciated

View 1 Replies View Related

Finding Location Of Listbox On SCREEN And Not On Form

Jun 11, 2014

I have code that finds the current position of the mouse on the screen in X,Y coordinates.

I am curious if there is something similar that can let me know the X coordinate (basically the .left function but for the screen) of a listbox?

View 3 Replies View Related

General :: Export A Query Of 14 Items To A Word Report?

Jun 17, 2013

Is there a way to export a query of 14 items to a word report. I have a table of 14 items in that I use as a query but it only exports 1 item to the report.

View 2 Replies View Related

Queries :: Mail Merge Some Of The Items Into Word To Be Used On Address Labels

Jun 27, 2014

So I have the following query which works perfectly (and will be use to create a report) but when the query runs to create the report I also want it to mail merge some of the items into word to be used on address labels.

Code:
SELECT Dunmow.Date, Dunmow.Undeliverable, Dunmow.Duplicate, Dunmow.[OTM with XXXXXX], Dunmow.[Landlords Salutation], Dunmow.[LL Address 1], Dunmow.[LL Address 2], Dunmow.[LL Address 3], Dunmow.[LL Address 4], Dunmow.[LL Address 5], Dunmow.[LL Postcode], Dunmow.[Letter 1], Dunmow.[Letter 2], Dunmow.[Letter 3], Dunmow.[Letter 4], Dunmow.[Letter 5], Dunmow.[Letter 6], Dunmow.[Letter 7], Dunmow.[Letter 8]
FROM Dunmow
WHERE (((Dunmow.Date)=DateAdd("d",-7,Date())) AND ((Dunmow.Undeliverable)=False) AND ((Dunmow.Duplicate)=False) AND ((Dunmow.[OTM with XXXXXX])=False) AND ((Dunmow.[Letter 1])=False));

So thats my query, What I want it to do is to take the following

[Landlords Salutation]
[LL Address 1]
[LL Address 2]
[LL Address 3]
[LL Address 4]
[LL Address 5]
[LL Postcode]

and use it for a merge item to create the labels required.

I have a standard word document/label document I wish to paste this into.

View 3 Replies View Related

Select All Items In A Listbox

Sep 21, 2005

How to code a "Select all" button to a multi select listbox named lbSeleccionePuerto

View 2 Replies View Related

Select All Items Ina Listbox

Oct 11, 2006

Does anyone know if its possible to select all items (that is turn all items black) in a listbox? thanks

View 1 Replies View Related

Listbox: Disable Some Items

Dec 7, 2007

I have a list box bound to a table. 3 columns (ID, item, open). only item is visible. The box contains forms or reports that will open on double click. The column open contains the name of the form or report to open

Some forms and reports are a work in progress, hence, they are still listed in the list box but the open value is blank and of course won't run.

I'd like to change the colour of the list list box items that won't run.

I'm thinking maybe some kind of If.. isnull type statement...

any ideas are appreciated.

View 4 Replies View Related

How To Determine Whether Or Not A Listbox Has Items Selected...?

Oct 6, 2006

Hello.

As my title states, that is my problem! I'm building search criteria from a form and have multiple list boxes... I want to be able to determine whether or not a list box has items selected or not. I have tried as many things as i knew how to with no luck...

Also, i searched the forum but could not find what i was looking for -_-

Thanks for any and all aide!

View 2 Replies View Related

General :: Edit Items In Listbox?

Aug 19, 2013

I have a listbox control on my form which works in conjunction with my search field on the first form. I can add new items with FRM_ItemsAdd. I can delete records by pressing the delete button.

However now I want the ability to Edit items in the list. How can I tell access I want to edit a record?

Attached is my access db.

View 1 Replies View Related

Modules & VBA :: Moving Items Between Listbox

Sep 9, 2014

I have two listbox (SearchResults5 has two columns) and list_asset_add (one column) both have Extended multi-selection active. I have this code that automatically moves the items between the two listbox (it runs after pushing a button):

Code:
Sub CopiTo_Click()
Dim Msg As String
Dim i As Variant
If SearchResults5.ListIndex = -1 Then
Msg = "Nothing"

[Code] ....

This works quite well if I manually select the items that I want to move. Most of the times SearchResults5 has lots of elements so I have decided to create a "Select All" button to speed up the process, here the code:

Private Sub Command271_Click()
Dim n As Integer
With Me.SearchResults5
For n = 0 To .ListCount - 1
.Selected(n) = True
Next n
End With
End Sub

When I use the "Select All" button and I try to move the items between the two listbox, the function does NOT work.

BUT if I manually select one or more items in the first listbox, then I clear the selection and finally I use the subroutine to move the items between the two listbox, then the it works well again. How to make it work properly.

View 5 Replies View Related

Recall Selected Items From Listbox Selection

Oct 24, 2005

Hi all, greate site and i have been able to solve most problems by using the search box although this problem is doing my head in...!!

I have a db that records project numbers and their details. I am using a listbox to allow a user to multiselect Project Involvements Tasks(ie Documentation, Build etc) against a project number.

I am able to read the selections into a separtate table with two columns which is structured as:

ProjectNo - InvolvementType
123 - Testing
123 - Build
123 - Documentation
456 - Build
789 - Testing
789 - Documentation

as you can see I dont have a problem getting the Itemsselected into a table... the problem that i am having is getting them out again when the record is displayed - ie marking them as itemsselected.

I believe that the event would be onCurrent which would loop through this table pick up the project number and recorded invovements and mark them as selected in the listbox. if there is no invovement then the listbox would show no selections.

I am using this code to read the selections in

===========================
'Records project involvements against project
Public Function AddInvolvements(ctlRef As ListBox) As String
On Error GoTo Err_AddInvolvements_Click

Dim i As Variant
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim qd As DAO.QueryDef
Dim strDelete As String

Set dbs = CurrentDb
Set qd = dbs.QueryDefs!qInvolvement
Set rs = qd.OpenRecordset

'Delete records where project number exists against an invovelment incase of involvement changes
strDelete = "Delete Project_Involvement.ProjectNo " & _
"FROM Project_Involvement " & _
"WHERE (((Project_Involvement.ProjectNo)=[Forms]![Add_Project_Details]![ProjectNo]));"

DoCmd.SetWarnings False
DoCmd.RunSQL strDelete
DoCmd.SetWarnings True

For Each i In ctlRef.ItemsSelected
rs.AddNew
rs!InvolvementType = ctlRef.ItemData(i)
rs!ProjectNo = Me.ProjectNo.Value
rs.Update
Next i
Set rs = Nothing
Set qd = Nothing

Exit_AddInvolvements_Click:
Exit Function

Err_AddInvolvements_Click:
Select Case Err.Number
Case 3022 'ignore duplicate keys
Resume Next
Case Else
MsgBox Err.Number & "-" & Err.Description
Resume Exit_AddInvolvements_Click
End Select

End Function
===================================

Any help would be much appreciated - also thanks to Pat Hartman for his excellent examples esp http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=54924

Regards
Robert

View 3 Replies View Related

Deleting Items From An Unbound Listbox And Table

Jan 10, 2006

I have a combo box that inserts data into an unbound list box and table. This works great but I am having trouble with the deletion part. I want to be able to dbl click on the item in the item list and delete it from both the list box and table. Currently, my code is deleting ALL items, not just the one item I want to get rid of. Any ideas would be most appreciated :)
This is what I have for the deletion code:

Private Sub List92_DblClick(Cancel As Integer)
DoCmd.SetWarnings False
sql2 = "delete from PROFILE_Industry where "
sql2 = sql2 & "profile_id = " & Me!Profile_ID
sql2 = sql2 & " And Industry_focus = '" & Me!List92.Value & "';"
DoCmd.RunSQL (sql2)
Me.Refresh
DoCmd.SetWarnings True
End Sub

View 3 Replies View Related

Modules & VBA :: Remove Multiple Items From ListBox

Aug 6, 2013

I'm trying to setup a listbox so that multiple items may be selected and removed at once. The Listbox Multi Select property is currently set to "Extended" and I have the following code on the onclick event of a command button:

Code:

Private Sub Command12_Click()
Dim i As Integer
For i = List10.ListCount - 1 To 0 Step -1

[Code]....

I have tested selecting 4 or so records on the list box and then pushing the remove button but it seems that the only record that is removed is the selected record that is furthest down on the listbox. The other selected records become unselected and must be reselected in order to continue removing records.

View 1 Replies View Related

Modules & VBA :: Updating Multiple Items In A Listbox

Jan 9, 2014

In my form I have the listFunctions list box set to Multi Select "Extended" in the following code contains a line to execute a query based on the selected items in a listbox. but for some reason instead of only changing the selected items it is changing all items in the listbox. I stepped through the code and it is looping the correct number of times based on the amount selected but is still changing all.

eg.if I select 3 items from the list, it loops through the execute 3 times.but the total 6 items will change.

Code:

Private Sub cmdEdit_Click()
Dim varItm As Variant
Dim sSQL As String
Dim ssSQL As String

[code]...

View 1 Replies View Related

Forms :: Move Multiple Items In A Listbox

Jul 13, 2013

I have a form with a listbox in which users should be able to move the items up and down. The listbox has 4 columns and multiple selection is enabled.

For a NON multiselect box I have it working, and also for a multiple selection box but in that case it works only for one row at a time.

For a NON multiselect listbox:

Code:
cmdDown_Click()
Dim i As Integer
Dim t1 As String, t2 As String, t3 As String, t4 As String
i = selectie.ListIndex
t1 = Nz(selectie.Column(0, i))
t2 = Nz(selectie.Column(1, i))

[Code] ....

You can select an item and then press "Down" as many times as you want to put the items as "down" in the list as you want it to be.

Multiselect listbox

This code also works for a multipleselection listbox when one item is selected, however, after you press "down" the item is still selected (highlighted) as the code reselects is (last line) BUT the value of selectie.listindex apparently is set to "-1".

Pressing "Down" again generates an error (i = -1). I can evade the error by adding "if selectie.listindex <=0 then exit sub", but that doens't fix the problem that the only way I can manage to reset the listindex to the new "position" of the item is to click on it again and THEN press "Down".

To fix this and be able to press "down" multiple times listindex should be set to the new value.

Adding a "me.selectie.listindex = i -1" doens't work (error), it seems like this value is readonly.

I can't find a way to "simulate" a mousepressed selection and really set the listindex.

The other problem is of course that this code doens't support moving multiple items at once: listindex points to the last selected item, but only one.

So, I tried another piece of code to move multiple items, not using listindex (since that resets to -1), but I run into another problem

Code:
Private Sub cmdDown_Click()
Dim var As Variant
Dim i As Integer
Dim n As Integer
Dim t1 As String, t2 As String, t3 As String, t4 As String
n = Me.selectie.ItemsSelected.Count

[Code] ....

The problem with this is: I can select multiple items and press "Down", but the problem now is that the selection is lost as soon as the code removes the first item, and the 2nd loop skips the if selected(i) = true (nothing is selected anymore).
The me.selectie.selected(i+1) = true doens't work since that would only reselect the first item after moving it.

The code "forgets" which items were selected and moves only one item...So I guess I need to put the indexnumbers in memory while moving the items.

I have been searching a lot, but can only find VB-solutions. In VB it's a lot simpeler using f.e. the .list property of a listbox, which is not available in MSAccess

The solution I'm thinking about is:

- set an array with the numbers of selected items
- put indexnumbers of the selected items in the array (f.e. 3 and 4)
- move items based on the indexnumers in the array
- when moving an item update the indexnumber in the array (3>4, 4>5)
- after moving all items reset the selection based on the array

It occurred to me then if I'm going to use an array anyway, I might as well load all items in an array, do the "resorting" and the reload the items in the list from the array. Might be more straightforward?

Btw...It seems VB has a simple solution to moving items: listbox.list(i) = listbox.list(i+1) or something like that moves an item. Even Excel seems to have this property but not MS Access!

View 1 Replies View Related

Forms :: Remove Multiple Selected Items From Listbox

Jul 24, 2013

How do I remove multiple selected items from listbox.

Noticed it is a table/query listbox, not value list.

Remove selected.zip

View 1 Replies View Related

Forms :: Count The Number Of Items Selected In Listbox?

Nov 1, 2013

I'm creating an employee audit database, and, in the audit form, the user (ie. supervisor) can select a number of items from a listbox. Each item selected corresponds to an error that the employee has made, and, as such, the employee's Audit Score has two points deducted for each item that is selected.

Incidentally, there are other, solitary elements to the form, but this particular listbox houses a collection of items that are related under a single category.

The score is displayed at the bottom of the form, and it needs to update in real-time.

The problems that I am encountering are that I am unable to count the number of items selected and then I am unable to multiply that count by 2 (the point-value of each item on the list.)

View 2 Replies View Related

Forms :: Concatenating Listbox Items - Column Data

Mar 18, 2013

I saw the following code on the forums...

Dim i As Integer, c As String
With Me.ListBox.Column(0)
For i = 0 To Me.ListBox.ListCount - 1
c = c & Me.ListBox.ItemData(i) & ", "
Next
End With
c = Left(c, Len(c) - 2)

This works great!! Now I am trying to concatenate the column 3 of the listbox.

Tried to use the code below (pointing to the second column) but it always returns the first column data.

'Dim i As Integer, d As String
With Me.ListBox.Column(2)
For i = 0 To Me.ListBox.ListCount - 1
d = d & Me.ListBox.ItemData(i) & ", "
Next
End With
d = Left(d, Len(d) - 2)

ItemData does not allow pointing to my 3 column of the listbox.

View 4 Replies View Related

General :: Subtract ListBox Items In Field Of A Table?

Sep 26, 2014

I have a form with a textbox, listbox and a button.

my textbox is based on one of my tables, and when I enter a value (which is saved in my table) in my textbox and press enter, certain values in my table goes to my listbox, and my listbox will just additem whenever I do same thing in my textbox all overagain.

how can I subtract listbox.column(1) items in my table field "Item_Quantity" where my Listbox.column(0) is equal to my table field "Item_Description".

My Listbox column count property = 4
Row source type = value list

View 1 Replies View Related

Modules & VBA :: How To Prevent ListBox From Unselecting Items After Right Click

Aug 12, 2013

i have a form that there is a list box inside that. after selection of items (usually 20 items) and right click the mouse on items it should open another pop up form,the problem is after right click selected items will be unselected except one item that there is mouse on that. how can i prevent list box from deselecting items after right click .

the code for mouse right click is like below:

Private Sub ItemList_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Const RIGHTBUTTON = 2
Dim udtPos As POINTAPI
Dim frm As Access.Form
If Button = RIGHTBUTTON Then
Set mp = New [*clsMousePosition]
GetCursorPos udtPos
DoCmd.OpenForm "frmshortcut"
DoCmd.MoveSize udtPos.x * mp.TwipsPerPixelX, udtPos.y * mp.TwipsPerPixelY
Forms!frmshortcut!txtparameter = Me.ItemList.Value
End If
End Sub

View 3 Replies View Related

Listbox That Passes To Database Values That Are Different From Shown Items?

Sep 11, 2012

I am trying to create a list box that passes to the database a value that is different from what shown in the drop down list. For instance, I want to show the users a drop down list with "Yes" and "No", but then storing into the database "1" when "Yes" is selected and "2" when "No" is selected.

View 1 Replies View Related

Adding Items...

Apr 7, 2006

I've made a button on my form which adds a booking ID into the listbox, but it doesn't seem to work. This is my code:

Private Sub Command18_Click()
Dim BoI As String

MsgBox "Booking successfully added!", vbInformation, "Booking"

If Month(Me.Date_1) = 1 Then
ListJ.AddItem Me.BoI
ElseIf Month(Me.Date_1) = 2 Then
ListF.AddItem Me.BoI
End If
End Sub

If someone could tell me the problem, I'd appreciate it. Thank you. :)

View 5 Replies View Related

Adding Items...

Mar 10, 2006

MsgBox "Booking successfully added!", vbInformation
'Depending on which month is booked, will determine which listbox is goes in on frmMain
If Month(Me.Date_1) = 1 Then
Forms!frmCurrentBookings!ListJ.AddItem = Me.BoI 'Add to ListJ on
frmCurrentBookings
ElseIf Month(Me.Date_1) = 2 Then
Forms!frmCurrentBookings!ListF.AddItem = Me.BoI 'Add to ListF on frmCurrentBookings
End If

End Sub

So basically... I have a date field in the form 'frmAddBooking'... if the month of the date is 1 (January), then the conntents of the date field is added to a listbox in a different form (frmCurrentBookings)... but this doesn't work...

If somebody could help me I'd appreciate it greatly.

View 2 Replies View Related







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