Hi Again,
After a bit more head scratching and cursing i have a solution to which i will post in case anyone else has a simular problem, the full code for the NotInList event is
Private Sub cboColour_NotInList(NewData As String, Response As Integer)
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
Response = acDataErrContinue
DoCmd.RunCommand acCmdUndo
Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
Style = vbYesNo + vbInformation + vbDefaultButton2 ' buttons
Title = "New Colour!" 'define title
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' If Yes Selected
MyString = "Yes"
DoCmd.OpenForm "frmColours", acNormal, , , acFormAdd, acDialog
MsgBox "Click the Drop Down List and select you new Colour"
'Repopulate cboColour and filter list for NewData
Dim sSubColourSource As String
sSubColourSource = "SELECT [tblColourCodes].[ColourID],[tblColourCodes].[ColourCode],[tblColourCodes].[ColourDesc] " & _
"FROM tblColourCodes " & _
"WHERE [ColourDesc] Like '" & NewData & "*'"
Me.cboColour.RowSource = sSubColourSource
Else 'If No Selected
MyString = "No" 'What to do
MsgBox "Please Select A Colour From the List"
End If
End Sub
The Bold text is what i added to make it work,
Cheers All
Darren
:D
|