N
NotGood@All
I have a Table named “SentToWhoâ€, with 2 fields, “SentToId†, AutoNumber &
SentTo, text, I have a form with a Combo box named “SendToId†& Control
Source is “SentToIdâ€, the Row Source is a query that uses the table
“SentToWhoâ€, with both fields. In the “On Not in List†I have the following
code but the combo box won’t let me tab away from it or enter the new record.
Private Sub SentToId_NotInList(NewData As String, Response As Integer)
Dim s As String
Dim mRecordID As Long
Dim mText As String
If Len(Trim(NewData)) = 0 Then Exit Sub
mText = StrConv(NewData, vbProperCase)
s = "INSERT INTO SentToWho (SentTo) " _
& " SELECT '" & mText & "';"
CurrentDb.Execute s
CurrentDb.TableDefs.Refresh
DoEvents
mRecordID = Nz(DMax("SentToID", "SentToWho"))
If mRecordID > 0 Then
Response = acDataErrAdded
Me.SentToId = mRecordID
Else
Response = acDataErrContinue
End If
End Sub
SentTo, text, I have a form with a Combo box named “SendToId†& Control
Source is “SentToIdâ€, the Row Source is a query that uses the table
“SentToWhoâ€, with both fields. In the “On Not in List†I have the following
code but the combo box won’t let me tab away from it or enter the new record.
Private Sub SentToId_NotInList(NewData As String, Response As Integer)
Dim s As String
Dim mRecordID As Long
Dim mText As String
If Len(Trim(NewData)) = 0 Then Exit Sub
mText = StrConv(NewData, vbProperCase)
s = "INSERT INTO SentToWho (SentTo) " _
& " SELECT '" & mText & "';"
CurrentDb.Execute s
CurrentDb.TableDefs.Refresh
DoEvents
mRecordID = Nz(DMax("SentToID", "SentToWho"))
If mRecordID > 0 Then
Response = acDataErrAdded
Me.SentToId = mRecordID
Else
Response = acDataErrContinue
End If
End Sub