Help with Command Button Code

  • Thread starter Thread starter Anthony W
  • Start date Start date
A

Anthony W

I am working in Access 2000 and currently I am trying to
delete a row from a table by using a command button. The
row to be deleted depends on an item selected in my list
box.

Command button is named:- cmdDeleteActivity
ListBox is named:- List3

This is the code I currently have on the OnClick Event of
the command button:-

Dim Title, Prompt, iReturn
Title = "Warning!"
Prompt = "Are you sure you want to Send this Learning
Activity" & vbCrLf & _
"to the Deleted Learning Activities Table?"
Buttons = vbYesNo + vbExclamation + vbDefaultButton2
iReturn = MsgBox(Prompt, Buttons, Title)
Select Case iReturn

Case vbYes
DoCmd.RunMacro "WarningOff"
DoCmd.RunSQL "Delete * from [Learning activity dataset]
where [learning activity dataset].[learn_id]='" & Me!
List3.Column(0) & "'" & " and [Learning activity dataset].
[provi_id] = '" & Me!List3.Column(1) & "'" & " and
[Learning activity dataset].[lprog_id] = '" & Me!
List3.Column(2) & "'" & " and [Learning activity dataset].
[lacti_id] = " & Me!List3.Column(3) & ""
Me.List3.Requery
DoCmd.RunMacro "Warningon"

Case Else
DoCmd.Beep
End Select

The problem I am having is I would only like to delete the
record if column(11) in my list box is null, but am unsure
of how to add this into the current code.


Any Help would be greatly appreciated.

Thanks in Advance All


Anthony
 
Maybe

IF IsNull(Me.List3.column(11)) Then _
DoCmd.RunSQL "Delete * from [Learning activity dataset]
where [learning activity dataset].[learn_id]='" & Me.
List3.Column(0) & "'" & " and [Learning activity dataset].
[provi_id] = '" & Me.List3.Column(1) & "'" & " and
[Learning activity dataset].[lprog_id] = '" & Me.
List3.Column(2) & "'" & " and [Learning activity dataset].
[lacti_id] = " & Me.List3.Column(3) & ""

will work?
Pavel
 
Back
Top