J
John P
OK I've done this ...
My form has a list box with Row Source Type = Table/Query
and Row Source as SELECT [listtbl] FROM Table3 ORDER BY
[listtbl]; My combobox is unbound. So the idea is to add
or delete the data from table3 and force the data to be
displayed the way you specify. Here's the code ...
Private Sub Addbtn_Click()
DoCmd.SetWarnings (False)
DoCmd.RunSQL "Insert into table3 (listtbl) values ('" &
Me.ComboBox & "')"
DoCmd.SetWarnings (True)
Me.ComboBox = ""
Me.ListBox.RowSource = Me.ListBox.RowSource
End Sub
Private Sub ComboBox_GotFocus()
Me.Addbtn.Enabled = True
Me.Removebtn.Enabled = False
End Sub
Private Sub ListBox_GotFocus()
Me.Addbtn.Enabled = False
Me.Removebtn.Enabled = True
End Sub
Private Sub Removebtn_Click()
Me.ComboBox = Me.ListBox
DoCmd.SetWarnings (False)
DoCmd.RunSQL "Delete from table3 where listtbl = '" &
Me.ListBox & "'"
DoCmd.SetWarnings (True)
Me.ListBox.RowSource = Me.ListBox.RowSource
End Sub
GOOD LUCK
My form has a list box with Row Source Type = Table/Query
and Row Source as SELECT [listtbl] FROM Table3 ORDER BY
[listtbl]; My combobox is unbound. So the idea is to add
or delete the data from table3 and force the data to be
displayed the way you specify. Here's the code ...
Private Sub Addbtn_Click()
DoCmd.SetWarnings (False)
DoCmd.RunSQL "Insert into table3 (listtbl) values ('" &
Me.ComboBox & "')"
DoCmd.SetWarnings (True)
Me.ComboBox = ""
Me.ListBox.RowSource = Me.ListBox.RowSource
End Sub
Private Sub ComboBox_GotFocus()
Me.Addbtn.Enabled = True
Me.Removebtn.Enabled = False
End Sub
Private Sub ListBox_GotFocus()
Me.Addbtn.Enabled = False
Me.Removebtn.Enabled = True
End Sub
Private Sub Removebtn_Click()
Me.ComboBox = Me.ListBox
DoCmd.SetWarnings (False)
DoCmd.RunSQL "Delete from table3 where listtbl = '" &
Me.ListBox & "'"
DoCmd.SetWarnings (True)
Me.ListBox.RowSource = Me.ListBox.RowSource
End Sub
GOOD LUCK