Rabu, 06 Agustus 2014

[MS_AccessPros] How to delete an item from drop down list of combo box

 

Hi all,

I have a sub form "Cst Payment of Members subform" it has a control "cboOutwardDeparturePort" having Row Source:
SELECT OutDeparturePort.OutwardDeparturePort FROM OutDeparturePort ORDER BY OutDeparturePort.OutwardDeparturePort;

On its Not in List event following is the code:

Private Sub cboOutwardDeparturePort_NotInList(NewData As String, Response As Integer)
    'On Error GoTo cboOutwardDeparturePort_NotInList_Err
    Dim intAnswer As Integer
    Dim strSQL As String
    intAnswer = MsgBox("Outward Departure Port '" & Chr(34) & NewData & _
        Chr(34) & "' is not currently listed." & vbCrLf & _
        "Would you like to add it to the list now?" _
        , vbQuestion + vbYesNo, "SCP - Guide")
    If intAnswer = vbYes Then
         strSQL = "INSERT INTO OutDeparturePort ([OutwardDeparturePort])" & _
                 "VALUES ('" & NewData & "');"
        DoCmd.SetWarnings False
        DoCmd.RunSQL strSQL
        DoCmd.SetWarnings True
        MsgBox "The new 'Outward Departure Port' " & Chr(34) & NewData & Chr(34) & " has been added to the list." _
            , vbInformation, "SCP - Guide"
        Response = acDataErrAdded
    Else
        MsgBox "Please choose a 'Outward Departure Port' from the list." _
            , vbInformation, "SCP - Guide"
        Response = acDataErrContinue
    End If
cboOutwardDeparturePort_Exit:
End Sub

User can add a new item in the list and been added to the table/list and has the option to add new item or not. If selection is No then he must select an item from the drop down list.
---------------------------------
My question is that if user adds an item which is wrong or an item which is no more required, how can remove/delete that item? Is there any option on the form to delete unwanted item or i have to make a separate form so that user selects the item to be deleted. Which is the right approach and method.

Need help please, because these type of combo boxes are on my many other forms, where this option is required.

Khalid

 

__._,_.___

Posted by: Khalid Tanweer <khalidtanweerburrah@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

Yahoo Groups
New feature! Create Photo Albums in Groups Effortlessly
Now, whenever you share photos with your group, a new album is automatically created in the Group. It's so simple! Try it now!


.

__,_._,___

Tidak ada komentar:

Posting Komentar