Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / September 2007

Tip: Looking for answers? Try searching our database.

Add to drop down menu.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
E-mail report using Lotus Notes rather t - 25 Sep 2007 18:50 GMT
Hi,

I have drop down menu in a form.  I programmed the high level drop down menu
(part number) to auto-populate other text fields in the form when the user
select a part number.  How do I program the part number drop down menu to
recognize a new part number when the user type in the part number text field.
Basically, when the user type a part number and the system does not
recognized it's in the drop down menu, a pop up screen will say, "this part
number is not in the drop down menu, would you like to add the new part
number?"  If yes, the new part number will automatically be added into the
drop down menu.  thanks.
SteveM - 25 Sep 2007 19:44 GMT
Are your Part Numbers in a table and the combo based on a query of that table?

If so, open a form on the PartNumbers table and add the record. When you
close the form you will return to the combo and the new item should appear in
your list.

Private Sub myCombo_NotInList(NewData As String, Response As Integer)
If MsgBox("This part number is not in the drop down menu, would you like to
add the new part number?",vbQuestion,"Add a new part number?") = vbYes Then
DoCmd.OpenForm "myForm", , , ,acFormAdd ,acDialog
End If
Me.myCombo.Requery
End Sub

If your table only has one column (doubtful for part numbers) you could just
use an INSERT query to insert the value entered, from NewData.

Private Sub myCombo_NotInList(NewData As String, Response As Integer)
Dim strSQL As String

If MsgBox("This part number is not in the drop down menu, would you like to
add the new part number?",vbQuestion,"Add a new part number?") = vbYes Then
strSQL = "INSERT INTO tblPartNumbers VALUES (NewData);"
CurrentDb.Execute strSQL, dbFailOnError
End If
Me.myCombo.Requery
End Sub

The second example could/would mean that new part numbers are added to a
table without any description or other information that I would have thought
any part number would need.

Anyway, hope that helps!

Steve

> Hi,
>
[quoted text clipped - 7 lines]
> number?"  If yes, the new part number will automatically be added into the
> drop down menu.  thanks.
E-mail report using Lotus Notes rather t - 25 Sep 2007 21:54 GMT
Hey Steve,

Wow...that's pretty awesome of you to give me two ideas and the codes.  What
I have now is when user select a part number from the drop down menu it will
auto-populate the description text field.  So if user want to add new part
number assoicated to the description the user will need to double click on
the part number text field and a form will open to allow user to add new part
# and description.  I don't have a query.  On the "Row Source" I used a
separate table with only part # and description.  Where do I put the code
"What event" onclick, on update, etc.

> Are your Part Numbers in a table and the combo based on a query of that table?
>
[quoted text clipped - 43 lines]
> > number?"  If yes, the new part number will automatically be added into the
> > drop down menu.  thanks.
SteveM - 26 Sep 2007 10:52 GMT
It depends what you want to do...

If you want a user to type a value in the combo and present you with the
form if it is not currently in the list - use the NotInList event. I gave you
examples of the code for that.

If you want to double-click on a text field, put it in the control's
DoubleClick event.

Steve

> Hey Steve,
>
[quoted text clipped - 54 lines]
> > > number?"  If yes, the new part number will automatically be added into the
> > > drop down menu.  thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.