challenge with the 'not in the list event'

S

Steve D

Borrowed this code out of Alison Balter's book ...
Private Sub countryID_NotInList(NewData As String, Response As Integer)
Dim intReply As Integer

intReply = MsgBox("The country you entered is not in the list. Would
you like to add a new country? ", vbYesNo)

If intReply = vbYes Then

DoCmd.OpenForm "frmAddCountry", , , , acFormAdd, acDialog, NewData

'-- Record added, so cancel Access' default processing
Response = acDataErrAdded

Else
MsgBox "Please select a country from the list."

Response = acDataErrContinue
End If

End Sub

It works fine but I would like to have the info that is 'not in the list' on
the frmTabbed be passed to the 'frmAddVendor' when the above code kicks in.

This is what i have on the OnOpen event

rivate Sub Form_Open(Cancel As Integer)

Dim strNewVendor As String
strNewVendor = Me.OpenArgs

If Nz(Len(Me.OpenArgs), 0) > 0 Then
DoCmd.GoToRecord , , acNewRec
Me.vendor = strNewVendor
End If

End Sub

It's not working and i have virtually no clue as to how to make this work.

H_E_L_P please!
 
A

Albert D.Kallal

This is what i have on the OnOpen event

The on open event is for testing conditions, and has the ability to "cancel"
the form load. If you cancel, then the form does NOT load....

Since you can cancel in the on-open event, then allowing modifications in
the on-open event would not make sense. In fact, this simply means that the
on open event is TOO soon to modify data..(you cannot).

Your code that sets up variables, and modifies fields should be in the
on-load event....
DoCmd.GoToRecord , , acNewRec

You do not need the above, as you already opened the form to a new record in
your openform command...

Me.vendor = strNewVendor

The above looks ok...you could have just well used

me.vendor = me.openargs.

However, as mentioned, this must be done in he on-load event....(the on-open
is too soon...and also has that cancel feature that means the form will NOT
load if you cancel = true).
 
S

Steve D

btw - THANK YOU !!!
--
Thanks,
Steve D


Albert D.Kallal said:
The on open event is for testing conditions, and has the ability to "cancel"
the form load. If you cancel, then the form does NOT load....

Since you can cancel in the on-open event, then allowing modifications in
the on-open event would not make sense. In fact, this simply means that the
on open event is TOO soon to modify data..(you cannot).

Your code that sets up variables, and modifies fields should be in the
on-load event....


You do not need the above, as you already opened the form to a new record in
your openform command...

Me.vendor = strNewVendor

The above looks ok...you could have just well used

me.vendor = me.openargs.

However, as mentioned, this must be done in he on-load event....(the on-open
is too soon...and also has that cancel feature that means the form will NOT
load if you cancel = true).


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.members.shaw.ca/AlbertKallal
 
S

Steve D

Awesome - this works!
--
Thanks,
Steve D


Albert D.Kallal said:
The on open event is for testing conditions, and has the ability to "cancel"
the form load. If you cancel, then the form does NOT load....

Since you can cancel in the on-open event, then allowing modifications in
the on-open event would not make sense. In fact, this simply means that the
on open event is TOO soon to modify data..(you cannot).

Your code that sets up variables, and modifies fields should be in the
on-load event....


You do not need the above, as you already opened the form to a new record in
your openform command...

Me.vendor = strNewVendor

The above looks ok...you could have just well used

me.vendor = me.openargs.

However, as mentioned, this must be done in he on-load event....(the on-open
is too soon...and also has that cancel feature that means the form will NOT
load if you cancel = true).


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.members.shaw.ca/AlbertKallal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top