add and remove button for combo Boxes

romio

Registered User.
Local time
Today, 09:05
Joined
Apr 20, 2005
Messages
68
Lets say that I have four combo Boxes on my form ’A’ I need to create another form ’B’ that will give the admin the permission to add or remove from these combo Boxes their values, do I need to create another form and simply add 4 combo Boxes and connect them to their source? What about the add and remove button is it done like VB? Can anyone help me with that?
 
romio,

You can implement the Add aspect by using the NotInList event of the combo.
For examples, use the Search Facility here and look for "NotInList", there
are plenty of samples.

Ask "Are you sure you want to Add?", then do a

"DoCmd.RunSQL "Insert into SomeTable (ComboField) Values ('" & Me.YourCombo & "')"

For deletions, you can add a button:

"DoCmd.RunSQL "Delete From SomeTable Where ComboField = '" & Me.YourCombo & "'"

For security, retain the info from a Login Form, or use the API calls and base
everything on the Windows UserName.

Wayne
 
Thanks WayneRyan.

I have used the below function to enter data and it works fine, however I am trying to make it more user friendly, what I want is that the user will type the new data in the comb Box and he will have to click on button to add it if the new data not is the list a msg will popup saying you new … has been added. Can the code be modified to handle that?

Thanks.

Code:
Private Sub addcomb_NotInList(NewData As String, Response As Integer)

Dim db As Database
    Dim strSQL As String
    If vbYes = MsgBox("'" & NewData & "' is not a current Category." & vbCrLf & "Do you wish to add it?", vbQuestion + vbYesNo, " ") Then
        Set db = DBEngine(0)(0)
        strSQL = "INSERT INTO [ACAAudio] ([Format]) VALUES('" & NewData & "');"
        db.Execute strSQL
        Response = acDataErrAdded
        Set db = Nothing
    Else
        Response = acDataErrContinue
    End If
        
End Sub
 

Users who are viewing this thread

Back
Top Bottom