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

Combo box question

Status
Not open for further replies.

Onslaughtdave

Programmer
Jan 24, 2005
59
CA
Hi all,

I have combo box's on a main form connected to a table per combo box. Another form i have updates/changes the table that each combo box is connected to. Is there a way having the main form open to have the combo box's update their info to match the info if they change the table?

ie:

employee name.

i have a table of employee names. if the name isnt in the combo box they want to add it so they open the employee entry screen do their stuff etc, then when they return to the one they looked through how do i make it refresh the combo box to show new values..

thanks,

dave

have a good weekend!
 
why not refresh?

_______________
conceptNEXT.com
[cN]
 
Or just do it from the form using the 'Not In List' Event:
Code:
Private Sub YourComboBoxNotInList(NewData As String, Response As Integer)
          If AskUser("YourTable") = True Then
                    DoCmd.SetWarnings False
                     ' Use code for your table
                    DoCmd.RunSQL ("INSERT INTO YourTable ( YourFieldName ) VALUES ('" & UCase(NewData) & "')")
                    DoCmd.SetWarnings True
                    Me.YourComboBox.Value = NewData
                    Me.YourComboBox.Requery
                    Response = acDataErrAdded
         Else
                    Response = acDataErrAdded
         End If
End Sub

Code:
Private Function AskUser(sTableName As String)
          Dim iAnswer As Integer
          
          iAnswer = MsgBox("The value you typed for ( " & sTableName & ") cannot be found in the lookup table." & vbCr & _
                    "Do you wish to save this value in the lookup table?", vbQuestion + vbYesNo, "Invalid Input Confirmation")
          AskUser = IIf(iAnswer = vbYes, True, False)
End Function

traingamer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top