Rabu, 06 Agustus 2014

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

 

John,

Your second option to provide an "Edit Airport Codes" button to pop open a dialog form that edits the IATA codes table appeals me nice. Shall work on that tomorrow its time for off now.

Take care & best regards,
Khalid


On Wednesday, August 6, 2014 5:25 PM, "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:


 
Khalid-

You would have to provide something like a command button on the form next to the combo box to activate code to delete whatever is the current value in the combo box, then requery the combo.  Or, provide an "Edit Airport Codes" button to pop open a dialog form that edits the IATA codes table.  If the user deletes a row on that form, be sure to Requery the combo box on the other form.

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)




On Aug 6, 2014, at 7:15 AM, Khalid Tanweer khalidtanweerburrah@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

John,

OK that is right. Nice thing.

But my question still is there suppose user added "KCI" deliberately and then it was found actual IATA airport code for Karachi is "KHI". Now when the user is using this form for other entries while his choice is "KHI" and pressing keyboard key K "KCI" is also there which is annoying for him as it is no more required in future.

Are you saying there is no option on the form for this control to delete/remove such entry?

regards,
Khalid


On Wednesday, August 6, 2014 5:07 PM, "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:


 
Khalid-

Your INSERT statement permanently adds the row to the table.  You would have to go to the form that edits that table to remove it.

To help ensure that values don't accidentally get added when the user simply presses Enter in response to your MsgBox, change it like this:

    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 + vbDefaultButton2, "SCP - Guide")

That makes the "NO" button the default if the user just presses Enter.  User has to specifically click the Yes button to add the value.

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)




On Aug 6, 2014, at 6:49 AM, Khalid Tanweer khalidtanweerburrah@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

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 (5)

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