Me.ShopName.Undo
DoCmd.OpenForm "pfrmShop", , , , acFormAdd, acDialog
Response = acDataErrAdded
Else
Me.ShopName.Undo
Response = acDataErrContinue
End If
End If
Pamela
The first part of the code depends on the user entering the text "None". Why
wouldn't they just leave it blank if it is supposed to be blank? BTW, " " is
a single space. Leave out the space ("") if you mean to have a zero-length
string. Make sure the table allows a zero-length string. I usually do not
allow a zero-length string, opting instead for Null. I don't see where that
comes into play in your code, but I thought I should mention it.
The way I have added an item using NotInList is based on this code:
http://www.mvps.org/access/forms/frm0015.htm
Note that you need to open a recordset. It may be possible to proceed as you
have done, but refresh the combo box in the next line after the code to open
the form, but I don't know, and don't have time right now to test.
If you are adding a record with a single field, the code in the link should
work after being adapted for the names you are using. If you are adding more
than one field to the new record you could use an input box or a series of
input boxes, or you could open a dialog form as you have done. However, when
you are done with the dialog form you need to hide it rather than close it,
so that the NotInList code can reference fields on the form. I won't go into
a lot of details without knowing some specifics. I suggest testing the code
in the link to add a single field. If that works but you need more fields,
post the code you have so far and a description of what needs to be added.
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201001/1
Try adding a Response line to the first branch of your If/Then statement.
For example:
If NewData ...
If MsgBox ...
Response = acDataErrContinue
Me.ShopName.Undo
Me.EstimateSend.SetFocus
Else
Response = acDataErrContinue
Me.ShopName.Undo
Me.ShpeName.SetFocus
End If
Else
...
Hope that helps...
I tried to respond to this post earlier but I don't think it went through,
so let me try again...
What I was saying was to try and insert a Response = acDataErrContinue lines
in the first branch of your If/Then statement. For example:
If NewData = "None" Then
If MsgBox ... Then
Response = acDataErrContinue
...
Else
Response = acDataErrContinue
...
End If
Else
...
Hope that helps...