Updating new item into a combo box list

Turbojohn

Registered User.
Local time
Today, 23:05
Joined
Aug 14, 2006
Messages
16
Hi,

I am using a combo box in my form. It is a growing combo box allowing new entries to be entered to create a growing list.

When new entries are made to the combo box list they are only displayed when I quit the form and then return to it. Is there any way I could allow the combo box list to grow dynamically rather than having to get the user to quit the form and then return to it?

Many Thanks
Turbojohn
 
Basically you need to requery the source

I take it that users are adding data and sometimes this will need an update to the combo box contents as the source of the combo is actually from the table into which data is being added...if so then

various ways.

use Got focus property of combo box and event procedure Me.Requery or is it Refresh

or on a previous field on got focus or lost focus event procedure Combo_name.requery

Len
 
Cheers Len,

Used the Me.Refresh on the combo box and it now updates properly.

Thanks for the help
Turbojohn
 
I had the same problem with a drop-down not populating immediately, and the Me.Refresh on the GotFocus event for the drop-down solved the problem.
Thanks!
 
WinDancer said:
I had the same problem with a drop-down not populating immediately, and the Me.Refresh on the GotFocus event for the drop-down solved the problem.
Thanks!

The only issue I have with doing a requery on a combo-box on the got focus is that it tends to "flash" when it updates. I don't think there is really any way around that though. :(
 
Hi

I used this code which I was kindly given by member here and it worked really well for me,

Private Sub Client_NotInList(NewData As String, Response As Integer)

Dim strSQL As String
Dim i As Integer
Dim Msg As String

'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub

Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Select yes to Quick Add then click on binoculars to to add more information"

i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Supplier...")
If i = vbYes Then
strSQL = "Insert Into tblClient ([Company]) values ('" & NewData & "')"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub

hope it helps
Fi
 

Users who are viewing this thread

Back
Top Bottom