NotInList Sub

G

Gil D.

Hello,

I have a combobox NotInList Sub:

Private Sub VehicleNumber_NotInList(NewData As String, Response As
Integer)

Dim intResponse As Integer
Dim vehicleNumber As String

vehicleNumber = NewData

DoCmd.OpenForm "AddVehicle", , , , , acDialog, vehicleNumber
Response = acDataErrAdded

End sub

My sub opens a pop up form named AddVehicle. In this form I have 2
commands button. First button adds the data to a table and the second
is cancel button.

My sub handles the first button click (add data).

How can I know which button was clicked when I'm back to
VehicleNumber_NotInList sub so I can handle cancel button click (undo
typing and avoid error message) ?

Thank you
Gil D.
 
A

Al Camp

Gil,
IMHO, using a seperate pop up form just to allow users to add a choice to
a combobox recordset is not inherently wrong... but a bit of overkill and
overhead for such a simple task. If you have 5 or 6 combos on a form that
would require a seperate form for each one?

Try using an InputBox instead of a form.

On my website (link below) I have a sample mdb that allows a user to add
a new entry to the combobox recordsource... or cancel that addition, and
then return the user to the original "calling" form with the new value added
to the combobox.

It's under Access Tips/ Not In List Combobox

There are many sites out there with similar freebie samples, or searching
the Access newsgroups will yield up many other simple solutions.
 
G

Gil D.

I did not write that in the pop up form the user adds additional data.

Thank you very much for your help. You solved my problem.

Gil D.
 

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