U
unclemuffin
I am using Access 2007. I have a form named frmRoll with control
RMItemNumber with the Limit to List property set to "Yes". This
control is bound to a field in the table tblWIPTable. I have event
code for the NotInList event for the RMItemNumber control.
When the user enters a new value that is not in the tblWIP, the code
properly opens the form frmWIPTable and populates the RMItemNumber
field with the NewData value that the user has entered. Once the form
is updated with the new information, I close the frmWIPTable. At this
point I get an Access window that says "The text you entered isn't an
item in the list".
The code in frmRoll:
Private Sub RMItemNumber_NotInList(NewData As String, Response As
Integer)
If NewData = "" Then Exit Sub
If MsgBox("'" & NewData & "' no es en la lista!" & Chr(13) &
Chr(10) & "¿Quiere añadir a la lista?", _ vbExclamation + vbYesNo) =
vbYes Then
DoCmd.OpenForm "frmWIPTable", , , , acFormEdit, acDialog,
NewData
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
the code in frmWIPTable:
Private Sub Form_Load()
Dim NewData As String
Me![cmdWIPStyle] = Me.OpenArgs
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.RunCommand acCmdRecordsGoToNew
End Sub
I have tried adding Me![RMItemNumber].Requery after the Response =
acDataErrContinue line but that gives me a '2118 error' - you must
save the current field before you run the requery action.
In order to combat the above error I added Me.Refresh before the Me!
[RMItemNumber].Requery line but this simply causes the NotInList event
to fire again which puts me in an endless loop.
TIA,
Brent
RMItemNumber with the Limit to List property set to "Yes". This
control is bound to a field in the table tblWIPTable. I have event
code for the NotInList event for the RMItemNumber control.
When the user enters a new value that is not in the tblWIP, the code
properly opens the form frmWIPTable and populates the RMItemNumber
field with the NewData value that the user has entered. Once the form
is updated with the new information, I close the frmWIPTable. At this
point I get an Access window that says "The text you entered isn't an
item in the list".
The code in frmRoll:
Private Sub RMItemNumber_NotInList(NewData As String, Response As
Integer)
If NewData = "" Then Exit Sub
If MsgBox("'" & NewData & "' no es en la lista!" & Chr(13) &
Chr(10) & "¿Quiere añadir a la lista?", _ vbExclamation + vbYesNo) =
vbYes Then
DoCmd.OpenForm "frmWIPTable", , , , acFormEdit, acDialog,
NewData
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
the code in frmWIPTable:
Private Sub Form_Load()
Dim NewData As String
Me![cmdWIPStyle] = Me.OpenArgs
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.RunCommand acCmdRecordsGoToNew
End Sub
I have tried adding Me![RMItemNumber].Requery after the Response =
acDataErrContinue line but that gives me a '2118 error' - you must
save the current field before you run the requery action.
In order to combat the above error I added Me.Refresh before the Me!
[RMItemNumber].Requery line but this simply causes the NotInList event
to fire again which puts me in an endless loop.
TIA,
Brent