Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing a table populated user contol combo box after addnew

Status
Not open for further replies.

Ads

Programmer
May 29, 2001
17
0
0
CA
Hey...

I have a combo box that I designed in a user control. The combo box is populated with a bunch of customers from a table called Customer during user control initiation (startup).

The customer adds data to the customer table via data entry on a "Add New Customer" Form.

The Question: When the user closes the "Add New Customer" form, how can I add the new name to the populated combo box on the main menu? I have tried to simply unload and then reload the main form, which does re-populate the combo, but turns the mouse pointer to a functioning hour glass.

Any advice would be appreciated. I know it is something ridilously easy that I am simply oversighting...

Thanks,
Ads
 
How do you populate the combo box in the first place?

Delete the items in the box and re populate it.

Merry Xmas!
 
Is the ComboBox bound to a datasource. If so try to refresh the datasource.

UncleT
 
The combo box is populated at run time (which also initializes the user control combo box).

The code to populate the combo is such:

Public Sub AddItem(Item As String)
If Item = "" Then Exit Sub
Combo1.AddItem UCase(Item)

If ItemsArray(0) = "" Then
ItemsArray(0) = Item
Else
ReDim Preserve ItemsArray(UBound(ItemsArray) + 1) As String
ItemsArray(UBound(ItemsArray)) = Item
End If
End Sub

Public Sub AddItems(ParamArray Items() As Variant)
Dim iCtr As Integer

Dim strSQLCustomer As String

strSQLCustomer = "SELECT Customer.CustomerID, Customer.FirstName, Customer.LastName, Customer.StreetAddress, Customer.City, Customer.PostalCode, Customer.PhoneHome, Customer.PhoneBusiness, Customer.ContractAuthorization, TanType.Description " & _
"FROM TanType INNER JOIN Customer ON TanType.TanTypeID=Customer.TanTypeIDFK " & _
"ORDER BY Customer.LastName;"

datCustomer.DatabaseName = App.Path & "\supertanDb.mdb"
datCustomer.RecordSource = strSQLCustomer

On Error Resume Next
Dim intCounter As Integer
intCounter = 0

With datCustomer
.Refresh

Do Until .Recordset.EOF
If .Recordset(&quot;LastName&quot;) <> &quot;&quot; Then

AddItem CStr(.Recordset(&quot;LastName&quot;) & &quot;, &quot; & .Recordset(&quot;FirstName&quot;))
Combo1.ItemData(intCounter) = .Recordset(&quot;CustomerID&quot;)
intCounter = intCounter + 1
End If
.Recordset.MoveNext
Loop
End With
End Sub


The AddItems function is called upon user control initialization. Could it be that- the add new form is using seperate data control bound to the same table as that of the main menu?

Thanks for your help...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top