Access 2007 data types supporting multiple values

K

Ken Warthen

In an Access 2007 table I'm using the new feature on a field (GroupMemberID)
that supports multiple values. I"ve set the Display Control property to List
Box and the Allow Multiple Values property to Yes. In Datasheet view the
field displays a drop down box with check boxes for all the GroupMemberIDs.
If you select a few they will be displayed in the field like 41, 52, 55.

In the same database I have a form that collects information and then adds a
record to the table with the GroupMemberID field. When I try to
programmatically add the record Access generates an error on the
GroupMemberID field. A sample of part of my code follows.

Has anyone worked with this new feature? If so, what's the trick to making
it work, and are there any known resources on this new feature?

Here's my code:

Private Sub cmdSave_Click()
On Error GoTo PROC_ERROR
' Add the entered data into tblEmailGroups and tblEmailGroupMembers
Dim strCompany As String
Dim strEmailGroupName As String
Dim strAffiliation As String
Dim strDSiProjectNumber As String
Dim sGroupMembers As String
Dim i As Integer
Dim strName As String
Dim rs As DAO.Recordset

Select Case Me.frameGroupAffiliation
Case 1 'Company Email Group
strAffiliation = "Company"
Case 2 'Project Email Group
strAffiliation = "Project"
For i = 0 To Me.lstNewGroupMembers.ListCount - 1
Debug.Print Me.lstNewGroupMembers.ItemData(i)
If i = 0 Then
'This is the first record
sGroupMembers = Me.lstNewGroupMembers.ItemData(i)
Else
sGroupMembers = sGroupMembers & "," &
Me.lstNewGroupMembers.ItemData(i)
End If
Next i
'Add record to tblEmailGroups
Set rs = CurrentDb.OpenRecordset("tblEmailGroups")
With rs
.AddNew
.Fields("GroupName") = Nz(Me.txtNewEmailGroupName)
.Fields("CompanyID") = Nz(Me.cboSelectCompany.Column(0))
.Fields("Affiliation") = strAffiliation
.Fields("AffiliationReferenceNumber") =
Nz(Me.cboAffiliatedProject.Column(1))
.Fields("GroupMemberID") = sGroupMembers
.Update
End With
rs.Close
Set rs = Nothing

Case Else
'Do nothing
End Select
Debug.Print sGroupMembers

PROC_EXIT:
Exit Sub
PROC_ERROR:
Call ShowError("cmdSave_Click", Err.Number, Err.Description, Err.Source)
Resume PROC_EXIT
Resume
End Sub

And the error number is 64224
The description: Method 'Value' of object 'Field2' failed

As usual, any help is greatly appreciated.

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top