A 2 part question.
SQL related with Spec combo box:
NotInList code:
QUESTION #1 SOLVED!
1) For some reason, txtMessage is not displayed on the form when NotInList is processed. I see it get populated properly in debug mode, but it never gets on the form. But txtMessage gets displayed normally in Add and Delete events.
It seems to do with the way NotInList works because txtMessage is displayed if I use acDataErrContinue. But that's not what I want; it leaves the combobox list open and can't save record if I close the form.
2) DLookup is used to extract the old Spec value to display in the message. I can see the old Spec in debug mode in cboSpec.column, but Listindex is -1 and unusable.
I don't know how to point to the proper record in the list. The only other way I can think of is to loop through the list comparing the Key, and then extract the Spec.
I don't know if it's more efficient to use lookup or loop.
(question #2 continues on post #5)
Robert
SQL related with Spec combo box:
Code:
SELECT S.Key, S.Spec FROM tblSpecs AS S ORDER BY S.Spec;
NotInList code:
Code:
Private Sub cboSpecs_NotInList(NewData As String, _
Response As Integer) ' MODIFY SPEC ENTRY.
10 Dim db As Database
20 Dim strSql As String
30 Dim strOldSpec As String
' Retrieve old data for Specs combo box entry.
40 strOldSpec = DLookup("Spec", "tblSpecs", "Key = " & cboSpecs)
' Modify tblSpecs entry for Spec combo box.
50 Set db = CurrentDb
60 strSql = "UPDATE tblSpecs SET Spec = '" & NewData & "' " & _
"WHERE Key = " & cboSpecs & ";"
70 db.Execute (strSql), dbFailOnError
80 db.Close
' Display process message.
[B][COLOR=darkred]90 txtMessage = "SPEC " & strOldSpec & " CHANGED TO " & NewData & "."[/COLOR][/B]
' Refresh Specs combo box.
100 Response = acDataErrAdded
' Update debugging fields.
110 txtSpecKey = cboSpecs
End Sub
QUESTION #1 SOLVED!
1) For some reason, txtMessage is not displayed on the form when NotInList is processed. I see it get populated properly in debug mode, but it never gets on the form. But txtMessage gets displayed normally in Add and Delete events.
It seems to do with the way NotInList works because txtMessage is displayed if I use acDataErrContinue. But that's not what I want; it leaves the combobox list open and can't save record if I close the form.
2) DLookup is used to extract the old Spec value to display in the message. I can see the old Spec in debug mode in cboSpec.column, but Listindex is -1 and unusable.
I don't know how to point to the proper record in the list. The only other way I can think of is to loop through the list comparing the Key, and then extract the Spec.
I don't know if it's more efficient to use lookup or loop.
(question #2 continues on post #5)
Robert
Last edited: