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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new data to list in cmbo box

Status
Not open for further replies.

smiley0q0

Technical User
Feb 27, 2001
356
US
I have a form that has a drop down combo box that is limited to the list. (the list is TblCompName)
When the user enters new data in, there is a button that allows them to add a new company to the list, the button opens a form where they just type in the new company and click a "done" button.. but the new company they just added is not available in the drop down box.
how can i see this new data in the combo box without having to close and reopen my form and still be on the same index number

thanks,
Smiley
 
Hi

In the button on click event, when you open the form to maintain the company table, open it as a modal form (acDialog in the DoCmd.OPenForm ....), after the DoCmd.OpenForm statement requery the combo control eg cboMyCombo.Requery

You can also do all of this in the notinlist event and save the button

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
how do i do it in the not in list event?
 
Hi

Example, you need to use your own form and control names of course, cmdNew_Click is a standard New Record button as generated by the wizard, so I have not repeated it here,

In the NotInList event of the combo box I have:

If MsgBox("Not in the List of Valid Warehouses, do you wish to add it?", _
vbYesNo, "Warning") = vbYes Then
DoCmd.OpenForm "frmWarehouses", acNormal, , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
Else
End If

The Combo box is set to limit to list = True, and the first column (ie the key column) is NOT hidden

In the called form (frmWarehouses) on open event I have:

Private Sub Form_Open(Cancel As Integer)
If IsNull(Me.OpenArgs) Then
Else
cmdNew_Click
strWarehouse = Left(Me.OpenArgs, 2)
End If
End Sub

and that works for me


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top