That was awesome. After I figured out what you were doing it turned out to work great.
With Warm Regards,
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265 Ext. 130
Fax (605)964-1070
"Valar Dohaeris"
From: "Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
To: "MS_Access_Professionals@yahoogroups.com" <MS_Access_Professionals@yahoogroups.com>
Sent: Tuesday, December 12, 2017 5:22 PM
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
Art,
Did you read my full reply with code to populate the text boxes?
Regards,
Duane
From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Tuesday, December 12, 2017 5:07 PM
To: Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
Sent: Tuesday, December 12, 2017 5:07 PM
To: Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
No the list box has 1 column. I need to move each list item value into a separate hidden textbox on the form. Then I move the value of the textbox into the appropriate field in the write statement
Something like
Me.txtIndexKeyLabel1 = me.lsteIndexFeilds.ItemData(1)
Me.txtIndexKeyLabel2= me.lsteIndexFeilds.ItemData(2)
And so on and so forth to a maxium count of 20.
With Warm Regards,
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265 Ext. 130
Fax (605)964-1070
"Valar Dohaeris"
On Tuesday, December 12, 2017 04:49:27 PM, Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Art,
So your listbox has many columns? Can you use something like:
Private Sub lsteIndexFields_DblClick(Cancel As Integer)
' code to update a value in a "value list" type listbox
' these changes will not be persisted once the form is closed
Dim strInput As String
Dim strItem As String
Dim intItem
strItem = Me.lsteIndexfields
strInput = InputBox("Edit This Item or start with + for a new item.", "Edit Me", strItem)
If Left(strInput, 1) = "+" Then
strInput = Trim(Mid(strInput, 2))
Me.lsteIndexfields.AddItem (strInput)
Else
Me.lsteIndexfields.RowSource = Replace(Me.lsteIndexfields.RowSource, strItem, strInput)
End If
Me.lsteIndexfields = strInput
'apply the item values to the text boxes
For intItem = 0 To Me.lsteIndexfields.ListCount - 1
Me("txtIndexKey" & Format(intItem + 1, "00") & "Label") = Me.lsteIndexfields.ItemData(intItem)
Next
End Sub
Again, I have no idea what your real world requirements are for this type of functionality.
Duane
With Warm Regards,
With Warm Regards,
With Warm Regards,
With Warm Regards,
With Warm Regards,
From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Tuesday, December 12, 2017 4:33 PM
To: Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
Sent: Tuesday, December 12, 2017 4:33 PM
To: Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
That works great but now it throws my whole code for writing to the table out the door. Now how do I pull out each individual item so I can write them to the appropriate field: This is my original code:
Private Sub cmdDone_Click()
Dim dbsCabinet As DAO.Database
Dim rstCabinet As DAO.Recordset
Dim txtArchiveKey As String
'Set fields
Me.txtArchiveKey = Format(Now(), "mmddyyhhmmss") & strCurrentUserName & "CAB"
Me.txtDateCreated = Format(Now(), "dd-mm-yy hh:nn")
Me.txtDateModified = Format(Now(), "dd-mm-yy hh:nn")
Me.txtDocMgrKey = MANAGERKEY
Me.txtArchiveGroupKey = ArchiveGroupKey
Me.txtIndexKey01Label = Me.lsteIndexFields.Column(0)
Me.txtIndexKey02Label = Me.lsteIndexFields.Column(1)
Me.txtIndexKey03Label = Me.lsteIndexFields.Column(2)
Me.txtIndexKey04Label = Me.lsteIndexFields.Column(3)
Me.txtIndexKey05Label = Me.lsteIndexFields.Column(4)
Me.txtIndexKey06Label = Me.lsteIndexFields.Column(5)
Me.txtIndexKey07Label = Me.lsteIndexFields.Column(6)
Me.txtIndexKey08Label = Me.lsteIndexFields.Column(7)
Me.txtIndexKey09Label = Me.lsteIndexFields.Column(8)
Me.txtIndexKey10Label = Me.lsteIndexFields.Column(9)
Me.txtIndexKey11Label = Me.lsteIndexFields.Column(10)
Me.txtIndexKey12Label = Me.lsteIndexFields.Column(11)
Me.txtIndexKey13Label = Me.lsteIndexFields.Column(12)
Me.txtIndexKey14Label = Me.lsteIndexFields.Column(13)
Me.txtIndexKey15Label = Me.lsteIndexFields.Column(14)
Me.txtIndexKey16Label = Me.lsteIndexFields.Column(15)
Me.txtIndexKey17Label = Me.lsteIndexFields.Column(16)
Me.txtIndexKey18Label = Me.lsteIndexFields.Column(17)
Me.txtIndexKey19Label = Me.lsteIndexFields.Column(18)
Me.txtIndexKey20Label = Me.lsteIndexFields.Column(19)
Set dbsCabinet = CurrentDb
Set rstCabinet = dbsCabinet.OpenRecordset("tblCabinets")
Dim dbsCabinet As DAO.Database
Dim rstCabinet As DAO.Recordset
Dim txtArchiveKey As String
'Set fields
Me.txtArchiveKey = Format(Now(), "mmddyyhhmmss") & strCurrentUserName & "CAB"
Me.txtDateCreated = Format(Now(), "dd-mm-yy hh:nn")
Me.txtDateModified = Format(Now(), "dd-mm-yy hh:nn")
Me.txtDocMgrKey = MANAGERKEY
Me.txtArchiveGroupKey = ArchiveGroupKey
Me.txtIndexKey01Label = Me.lsteIndexFields.Column(0)
Me.txtIndexKey02Label = Me.lsteIndexFields.Column(1)
Me.txtIndexKey03Label = Me.lsteIndexFields.Column(2)
Me.txtIndexKey04Label = Me.lsteIndexFields.Column(3)
Me.txtIndexKey05Label = Me.lsteIndexFields.Column(4)
Me.txtIndexKey06Label = Me.lsteIndexFields.Column(5)
Me.txtIndexKey07Label = Me.lsteIndexFields.Column(6)
Me.txtIndexKey08Label = Me.lsteIndexFields.Column(7)
Me.txtIndexKey09Label = Me.lsteIndexFields.Column(8)
Me.txtIndexKey10Label = Me.lsteIndexFields.Column(9)
Me.txtIndexKey11Label = Me.lsteIndexFields.Column(10)
Me.txtIndexKey12Label = Me.lsteIndexFields.Column(11)
Me.txtIndexKey13Label = Me.lsteIndexFields.Column(12)
Me.txtIndexKey14Label = Me.lsteIndexFields.Column(13)
Me.txtIndexKey15Label = Me.lsteIndexFields.Column(14)
Me.txtIndexKey16Label = Me.lsteIndexFields.Column(15)
Me.txtIndexKey17Label = Me.lsteIndexFields.Column(16)
Me.txtIndexKey18Label = Me.lsteIndexFields.Column(17)
Me.txtIndexKey19Label = Me.lsteIndexFields.Column(18)
Me.txtIndexKey20Label = Me.lsteIndexFields.Column(19)
Set dbsCabinet = CurrentDb
Set rstCabinet = dbsCabinet.OpenRecordset("tblCabinets")
'Add Record
rstCabinet.AddNew
rstCabinet!CabinetName = Me.txtCabinetName
rstCabinet!ArchiveKey = Me.txtArchiveKey
rstCabinet!CabinetMemo = Me.txtCabinetMemo
rstCabinet!DateCreated = Me.txtDateCreated
rstCabinet!CreatedByUSerID = intCurrentUserID
rstCabinet!DateModified = Me.txtDateModified
rstCabinet!ModifiedByUserID = intCurrentUserID
rstCabinet!DocMgrKey = Me.txtDocMgrKey
rstCabinet!ArchiveGroupKey = Me.txtArchiveGroupKey
rstCabinet!IndexKey01Label = Me.txtIndexKey01Label
rstCabinet!IndexKey02Label = Me.txtIndexKey02Label
rstCabinet!IndexKey03Label = Me.txtIndexKey03Label
rstCabinet!IndexKey04Label = Me.txtIndexKey04Label
rstCabinet!IndexKey05Label = Me.txtIndexKey05Label
rstCabinet!IndexKey06Label = Me.txtIndexKey06Label
rstCabinet!IndexKey07Label = Me.txtIndexKey07Label
rstCabinet!IndexKey08Label = Me.txtIndexKey08Label
rstCabinet!IndexKey09Label = Me.txtIndexKey09Label
rstCabinet!IndexKey10Label = Me.txtIndexKey10Label
rstCabinet!IndexKey11Label = Me.txtIndexKey11Label
rstCabinet!IndexKey12Label = Me.txtIndexKey12Label
rstCabinet!IndexKey13Label = Me.txtIndexKey13Label
rstCabinet!IndexKey14Label = Me.txtIndexKey14Label
rstCabinet!IndexKey15Label = Me.txtIndexKey15Label
rstCabinet!IndexKey16Label = Me.txtIndexKey16Label
rstCabinet!IndexKey17Label = Me.txtIndexKey17Label
rstCabinet!IndexKey18Label = Me.txtIndexKey18Label
rstCabinet!IndexKey19Label = Me.txtIndexKey19Label
rstCabinet!IndexKey20Label = Me.txtIndexKey20Label
rstCabinet.Update
' Close me
DoCmd.Close acForm, Me.Name
rstCabinet.AddNew
rstCabinet!CabinetName = Me.txtCabinetName
rstCabinet!ArchiveKey = Me.txtArchiveKey
rstCabinet!CabinetMemo = Me.txtCabinetMemo
rstCabinet!DateCreated = Me.txtDateCreated
rstCabinet!CreatedByUSerID = intCurrentUserID
rstCabinet!DateModified = Me.txtDateModified
rstCabinet!ModifiedByUserID = intCurrentUserID
rstCabinet!DocMgrKey = Me.txtDocMgrKey
rstCabinet!ArchiveGroupKey = Me.txtArchiveGroupKey
rstCabinet!IndexKey01Label = Me.txtIndexKey01Label
rstCabinet!IndexKey02Label = Me.txtIndexKey02Label
rstCabinet!IndexKey03Label = Me.txtIndexKey03Label
rstCabinet!IndexKey04Label = Me.txtIndexKey04Label
rstCabinet!IndexKey05Label = Me.txtIndexKey05Label
rstCabinet!IndexKey06Label = Me.txtIndexKey06Label
rstCabinet!IndexKey07Label = Me.txtIndexKey07Label
rstCabinet!IndexKey08Label = Me.txtIndexKey08Label
rstCabinet!IndexKey09Label = Me.txtIndexKey09Label
rstCabinet!IndexKey10Label = Me.txtIndexKey10Label
rstCabinet!IndexKey11Label = Me.txtIndexKey11Label
rstCabinet!IndexKey12Label = Me.txtIndexKey12Label
rstCabinet!IndexKey13Label = Me.txtIndexKey13Label
rstCabinet!IndexKey14Label = Me.txtIndexKey14Label
rstCabinet!IndexKey15Label = Me.txtIndexKey15Label
rstCabinet!IndexKey16Label = Me.txtIndexKey16Label
rstCabinet!IndexKey17Label = Me.txtIndexKey17Label
rstCabinet!IndexKey18Label = Me.txtIndexKey18Label
rstCabinet!IndexKey19Label = Me.txtIndexKey19Label
rstCabinet!IndexKey20Label = Me.txtIndexKey20Label
rstCabinet.Update
' Close me
DoCmd.Close acForm, Me.Name
But this no longer works because we only have one column in the listbox. How do I address each individual item?
Me.txtIndexKey01Label = Me.lsteIndexFields.Column(0) - this needs to change some how.
With Warm Regards,
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265 Ext. 130
Fax (605)964-1070
"Valar Dohaeris"
On Tuesday, December 12, 2017 04:13:57 PM, Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Art,
Is this what you are looking for?
Private Sub lsteIndexFields_DblClick(Cancel As Integer)
' code to update a value in a "value list" type listbox
' these changes will not be persisted once the form is closed
Dim strInput As String
Dim strItem As String
strItem = Me.lsteIndexfields
strInput = InputBox("Edit This Item", "Edit Me", strItem)
Me.lsteIndexfields.RowSource = Replace(Me.lsteIndexfields.RowSource, strItem, strInput)
Me.lsteIndexfields = strInput
End Sub
Regards,
Duane
From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Tuesday, December 12, 2017 3:05 PM
To: Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
Sent: Tuesday, December 12, 2017 3:05 PM
To: Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
OK I decided to eliminate the need for the popup form and use the list box AddItem and RemoveItem to achieve the same effect. I found some code on google which seems it the right direction but it needs some help...
Private Sub lsteIndexFields_DblClick(Cancel As Integer)
Dim az As Integer
Dim strInput As String
Dim Item As Object
Dim Index As Integer
az = Me.lsteIndexFields.Items.IndexOf(Me.lsteIndexFields.SelectedItem)
Item = Me.lsteIndexFields.Items.Item(az)
Index = Me.lsteIndexFields.Items.IndexOf(Item)
strInput = InputBox("Edit This Item")
Me.lsteIndexFields.Items.RemoveItem (ListBox1.SelectedItem)
Me.lsteIndexFields.Items.AddItem(index, strInput)
End Sub
Dim az As Integer
Dim strInput As String
Dim Item As Object
Dim Index As Integer
az = Me.lsteIndexFields.Items.IndexOf(Me.lsteIndexFields.SelectedItem)
Item = Me.lsteIndexFields.Items.Item(az)
Index = Me.lsteIndexFields.Items.IndexOf(Item)
strInput = InputBox("Edit This Item")
Me.lsteIndexFields.Items.RemoveItem (ListBox1.SelectedItem)
Me.lsteIndexFields.Items.AddItem(index, strInput)
End Sub
I need to put the selected item into the inputbox, change it and save it back. This is not VBA but it seems close. Can someone please give me and idea?
With Warm Regards,
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265 Ext. 130
Fax (605)964-1070
"Valar Dohaeris"
On Monday, December 11, 2017 04:28:16 PM, Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Art,
You have officially lost me 😉.
What is the "input box function" that populates the list box? What do you mean by "populates"?
I guess I need a more complete picture of what you are attempting to do in order to provide assistance since I'm making a ton of false assumptions. Maybe someone else has a better grasp of your forms and can help.
Regards,
Duane
From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Monday, December 11, 2017 2:48 PM
To: Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
Sent: Monday, December 11, 2017 2:48 PM
To: Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
My bad I skipped a part where I tell you that the list box unbounded and is populated by a input box function. The form does not get written to the table until the very end when the user click cmdDone which contains the table writes statements.
With Warm Regards,
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265 Ext. 130
Fax (605)964-1070
"Valar Dohaeris"
On Monday, December 11, 2017 02:44:45 PM, Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Art,
You said you tried "Refesh". What did you refresh? Did you try Requery the list box? This will only make a difference after the record in the table has been saved.
I have also used:
[Forms]![frmCabinetDetailsNew]![lsteIndexFields].RowSource = [Forms]![frmCabinetDetailsNew]![lsteIndexFields].RowSource
You could also open the second form in acDialog mode and add a line to requery the list box after the line to open the form.
Regards,
Duane Hookom
From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Monday, December 11, 2017 2:02 PM
To: Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
Sent: Monday, December 11, 2017 2:02 PM
To: Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
The user can may need to modify the an item in the list box. So let's say the Item they choose is Company and they want to change it to Company Name. The specification states I need to open a form and populate with the selected item from the list box and then save the changes back to the list box. I tried the Refresh and it did not work.
With Warm Regards,
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265 Ext. 130
Fax (605)964-1070
"Valar Dohaeris"
On Monday, December 11, 2017 12:56:24 PM, Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Hi Art,
You might want to try:
[Forms]![frmCabinetDetailsNew]![lsteIndexFields].Requery
I'm not sure why you are updating the list box but as long as you understand it's good with me.
Regards,
Duane
From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Monday, December 11, 2017 12:42 PM
To: Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
Sent: Monday, December 11, 2017 12:42 PM
To: Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]
Subject: Re: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
I got it to work when I am opening up the second for to edit the indexfield but after the edit when I want to update the listbox I tried this:
Private Sub cmdSave_Click()
If Not SaveIt() Then Exit Sub ' this is a save function
[Forms]![frmCabinetDetailsNew]![lsteIndexFields].Form.Requery
' Close me
DoCmd.Close acForm, Me.Name
End Sub
But it error's out with Object doesn't support this property or method
With Warm Regards,
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265 Ext. 130
Fax (605)964-1070
"Valar Dohaeris"
On Sunday, December 10, 2017 08:40:27 PM, Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
NArt,
Have you gotten anywhere with this? There is a double click event of the listbox to write your Code. You need to include OpenArgs to send a value to the form you are opening. When the new form is opened use Code to check the OpenArgs and set the control value.
Try it and let us know how far you get. If you have questions please come back with your Code.
Regards,
Duane
Get Outlook for iOS
From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of dbalorenzini@yahoo..com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Sunday, December 10, 2017 6:59:20 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
Sent: Sunday, December 10, 2017 6:59:20 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Populate Textbox On Another Form From Listbox,
I have a form called frmeCabinetDetailsNew and on it I have a listbox called lsteIndexField. If the user double clicks on a item in the list box I need to open up a from called frmeindexField which has a textbox called txtIndexField and populate it with the selected item from the listbox on the other form for editing. Once its edited I need to save the changes back to frmeCabinetDetailsnew.lsteIndexField. Any ideas?
Thank you,
Art Lorenzini
SD
__._,_.___
Posted by: Art Lorenzini <dbalorenzini@yahoo.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (19) |
Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.
.
__,_._,___
Tidak ada komentar:
Posting Komentar