473,394 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

help needed by a newbie - saving multi select values to a table

Hello,

i am a newbie at ms access, please help

this is a code i created to be able to get the multiple users i have selected in the form. i was able to select the users in the form an select folder however i am unable to save the user name to the table. i am able to save the folder name. what should i do?


Expand|Select|Wrap|Line Numbers
  1.  
  2.   Dim vtr As Variant
  3.     Dim frm As Form, ctl As Control
  4.     Set frm = Forms!Form_Assign
  5.     ctl = frm!listFolderUserList
  6.     ctr = ctl.ItemsSelected.count
  7.  
  8.     If ctr > 0 Then
  9.         selList = ctl.ItemsSelected
  10.         FolderID = Me.FolderName.Value
  11.         For Each vtr In Me.listFolderUserList.ItemsSelected
  12.           usrID = Me.listFolderUserList.ItemData(vtr)
  13.           sqlStr = "Insert into FolderLDAP (FolderID, UserID) " _
  14.           + "(" + FolderID + "," + usrID + ")"
  15.           CurrentDb.Execute sqlStr, dbFailOnError
  16.  
  17.       Next
  18.     End If
  19.  
  20.  
please help!

thanks,
lyanne
Mar 2 '08 #1
3 1385
ADezii
8,834 Expert 8TB
Hello,

i am a newbie at ms access, please help

this is a code i created to be able to get the multiple users i have selected in the form. i was able to select the users in the form an select folder however i am unable to save the user name to the table. i am able to save the folder name. what should i do?


Expand|Select|Wrap|Line Numbers
  1.  
  2.   Dim vtr As Variant
  3.     Dim frm As Form, ctl As Control
  4.     Set frm = Forms!Form_Assign
  5.     ctl = frm!listFolderUserList
  6.     ctr = ctl.ItemsSelected.count
  7.  
  8.     If ctr > 0 Then
  9.         selList = ctl.ItemsSelected
  10.         FolderID = Me.FolderName.Value
  11.         For Each vtr In Me.listFolderUserList.ItemsSelected
  12.           usrID = Me.listFolderUserList.ItemData(vtr)
  13.           sqlStr = "Insert into FolderLDAP (FolderID, UserID) " _
  14.           + "(" + FolderID + "," + usrID + ")"
  15.           CurrentDb.Execute sqlStr, dbFailOnError
  16.  
  17.       Next
  18.     End If
  19.  
  20.  
please help!

thanks,
lyanne
Assuming [FolderID] and [UserID] are Text, which you seem to indicate, the following code will do the trick:
Expand|Select|Wrap|Line Numbers
  1. Dim vtr As Variant, frm As Form, ctl As Control
  2.  
  3. Set frm = Forms!Form_Assign
  4. Set ctl = frm!listFolderUserList
  5.  
  6. ctr = ctl.ItemsSelected.Count
  7.  
  8. If ctr > 0 And Not IsNull(Me![FolderName]) Then
  9.   FolderID = Me.FolderName.Value
  10.   For Each vtr In Me.listFolderUserList.ItemsSelected
  11.      usrID = Me.listFolderUserList.ItemData(vtr)
  12.      sqlStr = "Insert into FolderLDAP (FolderID, UserID) " + "Values ('" + FolderID + "', '" + usrID + "')"
  13.        CurrentDb.Execute sqlStr, dbFailOnError
  14.   Next
  15. End If
Mar 2 '08 #2
FolderID is a number - PK and User ID is a text, is that the reason there is an error?
Mar 3 '08 #3
ADezii
8,834 Expert 8TB
FolderID is a number - PK and User ID is a text, is that the reason there is an error?
More than likely it is.
Mar 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: newbie_mw | last post by:
Hi, I need urgent help with a novice problem. I would appreciate any advice, suggestions... Thanks a lot in advance! Here it is: I created a sign-up sheet (reg.html) where people fill in their...
0
by: Mike Chirico | last post by:
Hopefully this will help someone... Helpful Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Last Updated: Fri Apr 16 11:47:34 EDT 2004 The latest version of this...
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
0
by: Suzanne | last post by:
Hello experts, I am a VBA newbie. Most of the tricks I apply to my applications I learn from here or google. I couldn't find a solution for the following two things, they both are related to...
8
by: newbie | last post by:
hello How can I update more than one tables on the same form? The relationship is one to many from a master table to 3 other related tables. on the form, I have to setvalue for a few...
11
by: Jim S. | last post by:
hi guys and gals, i have an array, but i have the hardest time putting the value in the table, so what is the normal procedure? thanks Jim
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
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...

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.