473,756 Members | 2,900 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help binding multiselect listbox to table

Hello,

I have created a form called frmS2P with the following:

1 listbox called List11 which holds the contents of a query created off
my table called tblRequestActio ns. The fields which the listbox holds
are Request_ID and MoveNumber.

1 text box called Date which is populated with the default value of
=Date( ).

1 combo box called Combo2 which is holds the contents of a query
created off my users table to display the names of managers.

1 button called Submit

I would like this form to allow managers to select multiple items from
the listbox and then use the combo box to pick there name and then
click the submit button.

Once the submit button is clicked I would like it to go find the table
tblRequestActio ns and populate the records that have been choosen in
the listbox by finding the Request ID in that table and updating the
DateSubmitted and SubmitAuthorize dBy fields with the contents of the
Date text box and Submitted By Combo2 box.

I have started on my own to write this code with help from searching
around and I can't figure out how or where to add the Date field in and
why it is not reading the field SubmitAuthorize dBy in the
tblRequestActio ns. I keep getting an error of method or data member not
found.

The code I have so far is:

Private Sub cmdSubmit_Click ()
Dim db As DAO.Database
Dim rst As DAO.Recordset
If Me.List11.Items Selected.Count = 0 Then
MsgBox "No items selected. Update operation aborted."
Exit Sub
End If
Set db = CurrentDb
Set rst = db.OpenRecordse t("tblRequestAc tions")
rst.Index = "Request_ID "
For Each itm In Me.List11.Items Selected
rst.Seek "=", Me.List11.ItemD ata(itm)
rst.Edit
rst.SubmitAutho rizedBy = Me.Combo2
rst.Update
Next
rst.Close
Set rst = Nothing
Set db = Nothing

End Sub
Could someone please point in the right direction here??

Thanks,
Justine

Mar 10 '06 #1
1 3301
On 9 Mar 2006 18:06:28 -0800, JN*****@gmail.c om wrote:

Looks like you're on the right track. A few points:
* After EVERY .Seek, the next line should be .NoMatch:
rst.Seek "=", Me.List11.ItemD ata(itm)
if rst.NoMatch then
MsgBox "Aaarrrrccchhhh !!!"
else
'normal processing
end if

* Rather than:
rst.SubmitAutho rizedBy = Me.Combo2
I would write:
rst!SubmitAutho rizedBy = Me.Combo2
Reason: a recordset doesn't have that property, like it has rst.EOF,
but it has such a field, and the ! notation can be used for that, or
you can write:
rst.Fields("Sub mitAuthorizedBy ").Value = ...
(the .Value part is not necessary because that's the default property,
but in .Net there are no default properties - might as well get used
to it.)

* Set a breakpoint at the top of this function and step through it.
It's easy to bind a dropdown list incorrectly, and where you think
Me.Combo2 returns an EmployeeID (long int), it may return text
unexpectedly. Inspect all values carefully in the debugger.

-Tom.
Hello,

I have created a form called frmS2P with the following:

1 listbox called List11 which holds the contents of a query created off
my table called tblRequestActio ns. The fields which the listbox holds
are Request_ID and MoveNumber.

1 text box called Date which is populated with the default value of
=Date( ).

1 combo box called Combo2 which is holds the contents of a query
created off my users table to display the names of managers.

1 button called Submit

I would like this form to allow managers to select multiple items from
the listbox and then use the combo box to pick there name and then
click the submit button.

Once the submit button is clicked I would like it to go find the table
tblRequestActi ons and populate the records that have been choosen in
the listbox by finding the Request ID in that table and updating the
DateSubmitte d and SubmitAuthorize dBy fields with the contents of the
Date text box and Submitted By Combo2 box.

I have started on my own to write this code with help from searching
around and I can't figure out how or where to add the Date field in and
why it is not reading the field SubmitAuthorize dBy in the
tblRequestActi ons. I keep getting an error of method or data member not
found.

The code I have so far is:

Private Sub cmdSubmit_Click ()
Dim db As DAO.Database
Dim rst As DAO.Recordset
If Me.List11.Items Selected.Count = 0 Then
MsgBox "No items selected. Update operation aborted."
Exit Sub
End If
Set db = CurrentDb
Set rst = db.OpenRecordse t("tblRequestAc tions")
rst.Index = "Request_ID "
For Each itm In Me.List11.Items Selected
rst.Seek "=", Me.List11.ItemD ata(itm)
rst.Edit
rst.SubmitAutho rizedBy = Me.Combo2
rst.Update
Next
rst.Close
Set rst = Nothing
Set db = Nothing

End Sub
Could someone please point in the right direction here??

Thanks,
Justine


Mar 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6367
by: Sally | last post by:
I have a simple multiselect listbox with a rowsorce of MemberID, MemberName, SendLetter. SendLetter is a Yes/No field. What is the code to set SendLetter to Yes when the user selects MemberName? I want to do this as the selections are being made not after-the-fact after all selections are made. Thanks! Sally
2
3357
by: Cassie Pennington | last post by:
I am trying to write various items from a multiselect list box to an SQL statement to update a report, without success. SQL only appears to accept hard-coded data or control values from a form, not variable data. Any clues as to how I can write several items to an SQL statement from a multiselect listbox to update a report? Thanks in anticipation Cassie
0
1152
by: deejayquai | last post by:
Hi I'm moving forward with a topic I've posted a couple of time before but still haven't cracked it, any further help is much appreciated. In a nutshell, I want to append either 1 or a selection of group members with either 1 or a selection of activity names into a assessment table called- tblAssessmentActivityProfile from 2 multiselect listboxes on a form. is the primary key I wish to append from
0
1343
by: Sanjin | last post by:
I have populated listbox with data from the datatable. I binded SelectedValue to the another datatable - i.e. selection result (with VS 20005 wizard). Selection result datatable has one column with type Int32.
1
6435
by: Peter | last post by:
Hi, I'm trying to create a form that shows table rows in a listbox. Several comboboxes expand the foreign key fields into text values from the parent tables, and there are also some textboxes for the non-foreign key fields. When the user clicks on a row in the listbox, the comboboxes' SelectedItem changes to reflect the foreign key selections in the currently selected row. That part is working fine. I also want the textboxes to change to...
3
3627
by: kaosyeti via AccessMonster.com | last post by:
hey... i have an unbound multiselect listbox on a form that i want to use to populate text boxes on that form. so if a user selects the 3rd item in a list of 20, how can i have that item show up in a text box? then, how can i have a second selected item show up in a different text box, without affecting the 1st one? (lboxOptions, txtboxOptions0, txtboxOptions1, etc..) -- Greg Message posted via AccessMonster.com
1
2463
by: ebernedo | last post by:
Hey guys, I have two main questions First off (pictures are kind of blurry) I have this table http://i197.photobucket.com/albums/aa109/ebernedo/DiscTable.jpg And thats my database I use my Form on I created a search form: http://i197.photobucket.com/albums/aa109/ebernedo/DiscSearchForm.jpg
5
4254
by: martin DH | last post by:
Hello, The details are below, but I have a simple form (Form1) with two objects and a "search" command button. When the two objects are cascading combo boxes (the form creates the parameters for a query - Query1), the query returns my results proper. But when the two objects are cascading combo-then-multiselect listbox (the perferred format in this case), the query always returns zero records. Tables: COMPILE (contains the records to be...
3
4088
by: Suresh62 | last post by:
I ahve two multiselect listbox for filtering report and printing. Now i want to update my table with flag saying its being printed and when the form is loaded again the flagged records should be filtered.How do i write VbA code for this. Can anyone help me please. I have been trying to get correct code for this. Thanks in advance.
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.