G
Gary Schuldt
I'm using the LimitToList and NotInList technique for the first time and
basically have the Event Procedure working.
I want to add more than one field to the new record, so I'm bringing up the
frmPlantSource in acAdd & acDialog mode to do that, and that seems to work.
However . . . I can't figure out a good way to get the NewData into the
appropriate field in the frmPlantSource. I mean, the user has already typed
it once, so they shouldn't have to do it again!
I thought of pushing the value in, but I can't push it until the frm is
open; but once opened, my code is suspended (because of acDialog), and I
don't get control back until its closed.
I could pull it in OnOpen, but then I'd have to test to make sure the form I
want to pull the cbx value from is actually open. That doesn't seem like
good design.
What's the best way to handle this?
I'll append the code. (I commented out a line of code I was using before I
changed the OpenForm to Dialog mode. I think in that version the
acDataErrAdded caused Access to requery the combo box before the record was
actually added by the popup form.)
Thanks
Gary
====================
Private Sub Plant_Source_ID_NotInList(NewData As String, Response As
Integer)
' Precondition: User keyed in a Plant Source name not in list (in
NewData)
' Action: Ask if wants to enter new one
' If so, bring up form in Add mode and push NewData into it
' If not, do nothing.
Dim sMsg As String
Dim intReply As Integer
Response = acDataErrContinue
If Not IsNull(NewData) _
Then
sMsg = "Do you wish to add a new Plant Source " & NewData & "?"
intReply = MsgBox(sMsg, vbYesNo + vbQuestion, "Add New Value")
If intReply = vbYes _
Then
DoCmd.OpenForm "frmPlantSource", , , , acAdd, acDialog
' Push in value (which user may override / modify)
' Forms!frmPlantSource!psName = NewData
' Tell Access to requery the combo box
Response = acDataErrAdded
' Else vbNo, do Nothing and exit
End If
Else 'NewData is null
MsgBox "Plant Source cannot be blank."
End If
End Sub
================
basically have the Event Procedure working.
I want to add more than one field to the new record, so I'm bringing up the
frmPlantSource in acAdd & acDialog mode to do that, and that seems to work.
However . . . I can't figure out a good way to get the NewData into the
appropriate field in the frmPlantSource. I mean, the user has already typed
it once, so they shouldn't have to do it again!
I thought of pushing the value in, but I can't push it until the frm is
open; but once opened, my code is suspended (because of acDialog), and I
don't get control back until its closed.
I could pull it in OnOpen, but then I'd have to test to make sure the form I
want to pull the cbx value from is actually open. That doesn't seem like
good design.
What's the best way to handle this?
I'll append the code. (I commented out a line of code I was using before I
changed the OpenForm to Dialog mode. I think in that version the
acDataErrAdded caused Access to requery the combo box before the record was
actually added by the popup form.)
Thanks
Gary
====================
Private Sub Plant_Source_ID_NotInList(NewData As String, Response As
Integer)
' Precondition: User keyed in a Plant Source name not in list (in
NewData)
' Action: Ask if wants to enter new one
' If so, bring up form in Add mode and push NewData into it
' If not, do nothing.
Dim sMsg As String
Dim intReply As Integer
Response = acDataErrContinue
If Not IsNull(NewData) _
Then
sMsg = "Do you wish to add a new Plant Source " & NewData & "?"
intReply = MsgBox(sMsg, vbYesNo + vbQuestion, "Add New Value")
If intReply = vbYes _
Then
DoCmd.OpenForm "frmPlantSource", , , , acAdd, acDialog
' Push in value (which user may override / modify)
' Forms!frmPlantSource!psName = NewData
' Tell Access to requery the combo box
Response = acDataErrAdded
' Else vbNo, do Nothing and exit
End If
Else 'NewData is null
MsgBox "Plant Source cannot be blank."
End If
End Sub
================