Referring to recordset field with variable

George Bowyer

Registered User.
Local time
Today, 23:21
Joined
May 17, 2004
Messages
50
Hi.

The following code returns an "Item not found in this collection" error so I am obviously trying to use the wrong way to refer to one of three yes/no fields in my recordset, defined by an optiongroup on the main form.


Dim db As Database
Dim rs1 As Recordset
Dim strCom As String
Dim NewCategory As Integer
Dim Title As String

Set db = CurrentDb()

If IsNull(lstNames) Then Exit Sub

Select Case optSelectCommittee
Case 1
strCom = "fldCom1"
Case 2
strCom = "fldCom2"
Case 3
strCom = "fldCom3"
End Select

Title = "Remove Record"
NewCategory = MsgBox("Do you want to delete " & lstNames.Column(0) & " from this Committee?", 33, Title)
If NewCategory = 1 Then

Set rs1 = db.OpenRecordset("tblCommittees", DB_OPEN_DYNASET)

rs1.FindFirst ("fldContNum = " & lstNames.Column(2))

rs1.Edit

rs1!strCom = False '** this is the bit that ain't working

rs1.Update

If (rs1!fldCom1 = False And rs1!fldCom2 = False And rs1!fldCom3 = False) Then rs1.Delete

rs1.Close


Can someone please tell me how I should be doing it.

Thanks.

George Bowyer
 
Ye gods! That was quick!

Works a treat. Thanks!

George
 

Users who are viewing this thread

Back
Top Bottom