-----Original Message-----
Hi,
You open the other form from the NotInList Event of the (combo box of
the) "main" form. The NotInList event supply for you the NewData value that
you can pass to the newly open form through the OpenArgs argument. In the
NotInList event of the main form, the logic CAN be like this:
' Ask a confirmation (is it a typo or really a new entry)
If vbNo=MsgBox("Do you want to add ... " , vbYesNo, ... ) Then
Response = acDataErrContinue ' if no need to further display any
error about this
Exit Sub
End If
' Here, open the new form
DoCmd.OpenForm ... , ..., windowMode:= acDialog, OpenArgs:= NewData
Response = acDataErrAdded ' assume the form we open did append the
right data
The mentionned book goes further in checking to see if the data did get
added, but for simplicity, what precede should work. Sure, in the form you
open, you open it only to let the end user adding extra info about the
record to be added. Here is another possibility, if the whole record is just
made of a single value, there is not need to open another form:
==========================
Private Sub EffectID_NotInList(NewData As String, Response As Integer)
If vbNo = MsgBox("[" & NewData & "] is new?", vbYesNo + vbQuestion,
"Confirm") Then
Response = acDataErrDisplay
Exit Sub
End If
CurrentDb.Execute "INSERT INTO Effects(Effect) VALUES (""" & NewData &
""")"
Response = acDataErrAdded
End Sub
============================
Here, I used an INSERT INTO to add the data in table Effects, its only
field, Effect. Since NewData is a string, my SQL string statement include
the proper string delimiters.
Hoping it may help,
Vanderghast, Access MVP
Michael,
I do not have that book. I think I follow what you say,
but this is not my living so I'm very unsure of my work.
When my form opens up the NewData (the item being added
to the list) does not go to the control on the now- opened
form. I have tried:
Forms![CallINGForm].[ControlOnCallINGForm]=
forms![CallEDForm].ControlOnCallEDForm
If I can just get the new item passed, I think I'd be ok.
I really don't understand the response =
acDataErrAdded/Continue for getting the new form to have
the control have that value.
Can you offer advice short of buying that book today.
I'll get it, just in a hurry due to the season.
Thanks.
Amber
-----Original Message-----
Hi,
In the NotInList event, the first argument, NewData As String, is the
data. You can assign Response, the second argument, to acDataErrDisplay
(default), acDataErrAdded (you added the data, ask Access to requery the
combo), or acDataErrContinue if you desire Access to continue as usual, but
without displaying the standard error message (because you added your own,
or otherwise).
If you have the book "Microsoft Office Access 2003 Inside Out", it on
page 863-next, with an example opening another form, indeed as it seems you
wish to do.
Hoping it may help,
Vanderghast, Access MVP
When I run across an item not in my list, and I want to
add it I use the NotInList event and open a form to add
some details associated with that new addtion to the
table.
How to I pass the value of that new list item (the one
that does not yet exist) to a form so that the list item
and details are all in my record?
Is this easy or hard?
I appreciate any help.
Amber
.
.