Updating information in a Table (please help me)

G

Guest

Hi

I'm trying to create a VBA event that will update the value in a field for a "Yes/No" field. Therfore, when the user double-click on the item in my list box, it will change the value form Yes to No or No to Yes. The code I have so far is below. But I can't get it to work and I can't figure out my mistake. Could someone point out my error(s)

Private Sub List2_DblClick(Cancel As Integer
' Find the record that matches the control
'Dim rs As DAO.Recordse
Dim rs As Objec

Set rs = Me.Recordset.Clon
'Set rs = CurrentDb.OpenRecordset("tbl_Risk Assessment"
'With rs.Fields("EntryNumber").SourceFiel
'.FindFirst (Str(Me![List2])

rs.FindFirst "[EntryNumber] = " & Str(Me![List2]
Me.Bookmark = rs.Bookmar

If rs.Fields("Include In Report") = -1 The
With r
.Edi
.Fields("Include In Report") =
End Wit
Els
With r
.Edi
.Fields("Include In Report") = -
End Wit
End I
'End Wit
Set rs = Nothin

Me.List2.Requery 'refresh values displayed in the list box windo

End Su

Dan
 
A

Alex Ivanov

Try to add
.Update

Alex.

Daniel said:
Hi,

I'm trying to create a VBA event that will update the value in a field for
a "Yes/No" field. Therfore, when the user double-click on the item in my
list box, it will change the value form Yes to No or No to Yes. The code I
have so far is below. But I can't get it to work and I can't figure out my
mistake. Could someone point out my error(s).
Private Sub List2_DblClick(Cancel As Integer)
' Find the record that matches the control.
'Dim rs As DAO.Recordset
Dim rs As Object

Set rs = Me.Recordset.Clone
'Set rs = CurrentDb.OpenRecordset("tbl_Risk Assessment")
'With rs.Fields("EntryNumber").SourceField
'.FindFirst (Str(Me![List2]))

rs.FindFirst "[EntryNumber] = " & Str(Me![List2])
Me.Bookmark = rs.Bookmark

If rs.Fields("Include In Report") = -1 Then
With rs
.Edit
.Fields("Include In Report") = 0
End With
Else
With rs
.Edit
.Fields("Include In Report") = -1
End With
End If
'End With
Set rs = Nothing

Me.List2.Requery 'refresh values displayed in the list box window

End Sub

Dan
 

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