hi guys i have form with a listbox . The listbox is coming from a query that
gets all passengers(colu mn 1 in listbox) and destinations(co lumn 3) . so you
have repeting rows of passengers since they could have up to three
destinations. Then the user has to select a row in the list box , double
click even in my listbox i have to sql query to delete the currect item
selected (passenger with destination). this works fine. however i need to put
some kind of code so then when there is a recordcount of 1 of the current
destination, then you can't delete. Meaning that each passenger must have at
least one destination. I already put in the table not to allow any nulls in
for destinations, but still it lets you delete the last destination.
this is what i have so far:
Private Sub cmdDelete_Click ()
Dim dbs As DAO.Database
Dim strSQL As String
If Me.List33.Recor dset = 1 Then
MsgBox " you must have at least one Destination "
DoCmd.CancelEve nt
Set dbs = CurrentDb
If MsgBox("Are you sure you want to delete the selected Destination?",
vbYesNo) = vbYes Then
strSQL = "UPDATE tblPassengerDes tination Set Dest_Status = ""Inactive" " WHERE
ID = " & List33.Column(0 )
DoCmd.RunSQL strSQL
MsgBox "Your Destination has been deleted"
Me.List33.Reque ry
Else
DoCmd.CancelEve nt
End If
--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200610/1