Modules & VBA :: Create Multiple Word Documents From ListBox MultiSelect?
Jul 31, 2013
I created a form with a ListBox and a Command Button. The users selects the values in the listbox and then click the button to create word documents. I've written VBA code to accomplish this. But it's not working properly. It opens multiple word documents but all for the same one.
Private Sub Command6_Click()
Dim appWord As Object
Dim varItem As Variant
Dim strPathToTemplateFile As String
Dim strPathToProspectiveFile As String
Dim strPreferredFileName As String
For Each varItem In Me.List0.ItemsSelected
[code].....
View Replies
ADVERTISEMENT
Apr 19, 2005
I have a table, "people" which has all the main data stored. I have another table, "organizations" which I'd like to be able to use on a form to select which organizations people belong to. I created a button on my main form which opens another form on which a listbox with all the organizations shows. What I'd like to do is from the main form, click a button that brings up a new form. On the new form, I can select the affiliations. Then, when I close that form, a box on the main form shows what i've just selected. I got this to work with the listbox, but when I changed it to multi-select it stopped working. Help!! Thanks.
View 5 Replies
View Related
Jun 25, 2005
I want to be able to select multiple items from a listbox, click a button, and then print the data related to that item selected using a report.
In the report to print the data, I have added the criteria
[Forms]![Print Labels]![List2]
This is the name of the listbox. However, this doesn't print the items selected in the list box.
Do I have to do this through VBA, or can I accomplish this through a query in the report?
Thanks!
View 1 Replies
View Related
Jun 9, 2006
Hi all,
Sorry but I'm really new to Access and trying to make sense of all the useful advice on here!
I'm trying to programme a button in one of my forms to open up a word document as read-only. I've written the code to open up the Word application (before I found the button which did it for me! :( ) but I think I need to add one or two more lines so that word knows where the document is I want and opens it up - any ideas what these lines are?
Real sorry for the trouble - any help would be most appreciated! Thanks guys and girls.
View 4 Replies
View Related
Jan 28, 2005
I was wondering whether it is possible to select multiple values in a list box on a form that can be stored in a table.
View 4 Replies
View Related
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
Feb 27, 2008
As a basic user and relatively new user of Access, I have designed a database which holds the data for several word documents that I use for mailmerges. I want to be able from the "switchboard" link the word documents so that users can easily access the letter/form required and print them. Ive tried many things - just not working!!!! Time to shout for help!
View 1 Replies
View Related
Feb 18, 2006
Hi all..
I am new to Access and currently implementing a small company database.
Is it possible to link Access to Word documents?
I wish to create a button on a form that when clicked it opens the word document according to what have been selected in the combo box in the form.
thanks :o
View 8 Replies
View Related
Jan 26, 2005
I'm trying to create a database where a single "Classification" field is populated by selections made in a multiselect listbox and I can't figure out how to do this. Any help people can provide?
Table 1:
Name_ID <pk>
Name
Classification
Table 2:
Classification_ID <pk>
Classification
What I want to happen is click on a button next to the Classification field (text) and a popup form with a multi-select list loads (this part is easy, of course). The user can select as many classifications as they want, click the ok button and each item selected then goes back to the first form and populate in the Classification field (seperated by commas or semi-colons).
This possible?
View 3 Replies
View Related
Jan 27, 2005
Hi,
I have adapted code from ghudson's example on
'http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=52736
I have a subform called frmsJobPartsUsed, which contains a multiselect list box where the user can select multiply parts used for one job and click a save button, which saves the parts to rows on the same forms (see picture). The user then enters the number used and that number is taken away from the UnitsInStock.
This form is made up of the following two tables;
TblStore
PartNo
PartName
UnitsInStock
ReOrderLevel
Discountinued
Remark
tblPartsUsed
PartUsedID
JobDetailsID
PartNo
PartUsedNum
NumberUsed
The multiselect listbox is made form tblStore, PartNo, PartName and Discontinued = 0
This all works fine so far.
What is need to do is before the parts selected are saved to the table I want to run some code to check
If a part’s UnitsInStock is equal to 0 then Message box saying no stock left need to reorder. It won’t save it to the table.
Or else
If UnitsInStock is greater than 0 but less than or equal to ReOrderLevel
Message box saying Stock running low need to reorder asap.
I have this kind of working but it doesn’t seem to be finding the correct UnitsInStock for the part selected.
Here is the code;
Private Sub cmdAnswer_Click() 'SAVE BUTTON
On Error GoTo ErrMsg:
'Code adapted from ghudson's example on
'http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=52736
Dim myFrm As Form, myCtl As Control
Dim mySelection As Variant
Dim iSelected, iCount As Long
Dim myDB As DAO.Database
Dim myRst As DAO.Recordset
Dim myRstCount As DAO.Recordset
Set myDB = CurrentDb()
Set myRst = myDB.OpenRecordset("tblPartsUsed")
Set myFrm = Me
Set myCtl = Me.lstAnswers
iCount = 0
'Count number of selected records/items
For Each mySelection In myCtl.ItemsSelected
iCount = iCount + 1
Next mySelection
'Check if anything is slected
If iCount = 0 Then
MsgBox "There are no Parts selected..", _
vbInformation, "Nothing selected!"
Exit Sub
End If
StrSQLCount = "SELECT tblPartsUsed.JobDetailsID, Count(tblPartsUsed.PartNo) AS CountOfPartNo " & _
"FROM tblPartsUsed " & _
"GROUP BY tblPartsUsed.JobDetailsID " & _
"HAVING (((tblPartsUsed.JobDetailsID)=" & [Forms]![frmJobs]![JobDetailsID] & "));"
Set myRstCount = myDB.OpenRecordset(StrSQLCount, dbOpenSnapshot)
'SART OF MY CODE TO CHECK FOR UNITSINSTOCK
For Each mySelection In myCtl.ItemsSelected
If Me.UnitsInStock.Value = 0 Then
MsgBox "Out of Stock!" & Chr(13) & "Please returen to Orders or Store to Re-Order Stock. " & Chr(13) & " ", vbOKOnly + vbCritical, "Re-Order Stock"
myCtl.Selected(mySelection) = False
Else
If Me.UnitsInStock.Value > 0 And Me.UnitsInStock <= Me.ReOrderLevel.Value Then
MsgBox "The Store is running low on stock!!" & Chr(13) & " Please return to Orders or Store to re-order as soon as possible.", vbInformation, "Need to Re-Order Stock"
End If
End If
Next mySelection
'END
iCount = 0
'Go throught each selected 'record' (ItemsSelected) in listbox
For Each mySelection In myCtl.ItemsSelected
'Current count of selected items
iCount = iCount + 1
'Print value to Immediate Window
Debug.Print myCtl.ItemData(mySelection)
'Add answers
With myRst
.AddNew
.Fields("JobDetailsID") = Forms![frmJobs]![JobDetailsID]
.Fields("PartUsedNum") = iCount
.Fields("PartNo") = myCtl.ItemData(mySelection)
.Update
End With
Next mySelection
'Requery form
Me.Requery
ResumeHere:
Exit Sub
ErrMsg:
MsgBox "Error Number: " & Err.Number & _
"Error Description: " & Err.Description & _
"Error Source: " & Err.Source, vbCritical, "Error!"
Resume ResumeHere:
End Sub
Private Sub cmdUnselect_Click() 'UNSELECT BUTTON
On Error GoTo ErrMsg:
'Code adapted from ghudson's example on
'http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=52736
Dim myFrm As Form, myCtl As Control
Dim mySelection As Variant
Dim iSelected, iCount As Long
Set myFrm = Me
Set myCtl = Me.lstAnswers
'Count number of selected records/items
For Each mySelection In myCtl.ItemsSelected
iCount = iCount + 1
Next mySelection
If iCount = 0 Then
MsgBox "There are no selections to Un-Select..", _
vbInformation, "Nothing selected!"
End If
'Go throught each selected 'record' (ItemsSelected) in listbox
For Each mySelection In myCtl.ItemsSelected
Debug.Print myCtl.ItemData(mySelection)
myCtl.Selected(mySelection) = False
Next mySelection
ResumeHere:
Exit Sub
ErrMsg:
MsgBox "Error Number: " & Err.Number & _
"Error Description: " & Err.Description & _
"Error Source: " & Err.Source, vbCritical, "Error!"
Resume ResumeHere:
End Sub
Any help would be greatly appreciated.
Thanks in advance
Rita
View 1 Replies
View Related
Apr 19, 2005
OK - I have seen the other posts where individuals are trying to select multiple items from a list box and have a field populate with the selections. I have not seen a clear explanation defining if this is possible.
Essentially, I want to be able to query on the field and search for multiple selections within that field. Any recommendations as to how this can be achieved?
My next question, is if the selections in a multiple instance field are separated by a comma or some other character what is the best method to query for multile responses. For example, if the following data is in the field 1,2,3 and I want to query on 1 or 2?
Regards,
PolarBear
View 3 Replies
View Related
Jan 25, 2008
I was wondering if there is an awesome way out there somewhere to take a record and export it into a word document, like a template and have the fields go where you want them to?
View 13 Replies
View Related
Mar 22, 2014
I have a database with hyperlinks to open word documents on my network. If someone else has that word document open it will ask me if I want to notify or open in read only. However since upgrading to Access 2013, (from Access 2003), this sometimes freezes the database.
I am wandering is there a way to tell Access (or Word) to open the document in read only if there is someone using it already?
View 1 Replies
View Related
Apr 21, 2015
I am attempting to create a database where I can input a number that will display a word document, and pdf's, and be able to toggle through them. I have all the data compiled. I just need to present it in some type of a front.
View 2 Replies
View Related
Jul 4, 2015
I have a set of maybe 5 template word docs which I populate with info form our database using bookmarks , the word docs are currently sat in a shared network drive.
I have started wonder if it would be better to store them in a table and call them from there to keep things together.
View 1 Replies
View Related
Dec 12, 2006
Hi, i was wondering if it's possible in a listbox with the multiselect option set to extended simply click on a field and open a form with the data of this field..
example:
i've a listbox of my customers, (only first and last name)..i click on one of this and a new form with all the details'll open, so i can see and modify stuff...
with the multiselect set to none this works..but with the extended??
(btw..i wanna just click on one filed, but i need the extended multiselection on for other options..)
thx in advance
View 14 Replies
View Related
May 22, 2014
Is it possible to have a multiselect listbox on a subform with a datasheet view or do I need a combobox in this situation?
View 4 Replies
View Related
Apr 18, 2006
Hi all,
i need help regarding linking Access to various Word documents.:confused:
the task consists in choosing a particular Country, Year and Month from Combo Boxes and then view the related reports in Word.
for example : United Kingdom, 2006, January
more than one report can be related to a particular country.
is there a way this can be done? (maybe through the use of LookUp for the folder path?!)
any help will be much appreciated.
thanks.
View 1 Replies
View Related
May 10, 2006
Hi. I have been asked to find out if it is possible to automatically insert info from a access database into some word documents that require the same info i.e. a title or reference number so that, for example, if the title is changed in the database it will automatically change in the associated word documents.
Is this even possible as I have no idea or can something similar be done?
Thanks for any ideas!
View 1 Replies
View Related
Jan 17, 2007
Hi,
My situation:
A front end written in Access (back end mySQL).
I have made a .mde file out of this front end.
There are a number of MS Word documents used (as merge documents) for running reports and letters that are linked to queries in the database. However, I can only link these documents to the original .MDB file as you can't link to the queries ni the .mde file.
This works fine until you have a query that requires a parameter from a form. The user will have selected the parameter from the .mde version of the front end that they are using but the query which is being called from the .mdb version (by the Word merge document) can't see this parameter because it is a totally separate database.
How can I get around this problem?
Sorry this is a lengthy post, hope it makes sense.
Matt.
View 4 Replies
View Related
Apr 21, 2014
I would like to use a listbox set to multiselect to add records to a junction table. I've been using code to accomplish this with checkboxes (love how it looks and works) but after moving my tables to Office 365 as the backend, linkedto a local frontend, sql does not like this particular set up, and I do not have the time or knowledge to sort out why. So what I need is a step by step to look at the many, in this case possible roles a contact can have, and choose one or more, which then creates a record in the junction table with the contact id and role id.
I would prefer to not use a combobox on a continuous form because every time a user goes to select roles he would have to scroll through all the choices for each separate role.
View 5 Replies
View Related
Sep 2, 2013
I've got a form with a multiselect listbox (extended) that holds a very long list of items (~90,000):
1 | Apple
2 | Orange
3 | Banana
...............
35313| Corn cob
...............
The user can select multiple items (non-sequential) on the listbox, say items 1 and 35313. I'd like the listbox to scroll (meaning display) to the currrently selected item, so that the user can see it while being processed.
I've seen stuff about property ListIndex, which does exactly that, but it's only useful when you have just ONE item selected (in a multiselect listbox apparently it deselects the rest of the items, so no point in using it, I guess, unless there's more to it!!).
So the key here is how to do the scrolling/display.
The code to loop through the listbox and process each selected item is attached:
Code:
Dim vItem As Variant
Dim Content as String
For Each vItem In Me.lst.ItemsSelected
'scroll to selected item ???
'processing of the selected item
Content = Me.lst.Column(1, vItem) 'copy the content to do sth with it
Me.lst.Selected(vItem) = False 'unselect the current item
Next vItem 'go to next selected item
how to scroll to the currently selected item? Mind that I need to go through the list of selected items to process them for further use (i.e, I need them selected).
View 4 Replies
View Related
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
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
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
Aug 4, 2013
I have multiple tables (Desktops and Telephones)
A search form, to search into those tables (It searches by "User")
The search form contains a listbox that shows results (listPC)
And the following code:
Option Compare Database
Dim strUserPC As String, strUserTel As String
Dim db As DAO.Database, rsUserPC As DAO.Recordset ', rsUserTel As DAO.Recordset
Private Sub txtSearch_LostFocus()
strUserPC = ""
strUserTel = ""
[Code] .....
It works, but I have one problem. It only shows telephones or desktop, not both. It deppends on which line inside UpdateList is first.
That example searches into 2 tables:
-Telephones
-Desktops
And searches by "user".
I want to list all telephones and desktops that a user has assigned.
What should I change to show both results?
View 9 Replies
View Related