Hi -
I have a combo box in a form from a table called 'client names'. I would like users to be able to select name and also add a new name to the combo box, which would also add to the table 'clients name'.
What I have now, is user only able to select a name from combo box but not add unless they exit form and add to table.
Can't seem to figure this one out.
Thanks!
7 1353 NeoPa 32,556
Expert Mod 16PB
Unfortunately, this is not possible in a ComboBox.
A ListBox can have an item entered which is not in the current list but I don't think you can trigger an addition to any table that way.
What I think you need is a form structure for adding your record. Possibly selected (filtered) by your ComboBox entry.
Hi -
I have a combo box in a form from a table called 'client names'. I would like users to be able to select name and also add a new name to the combo box, which would also add to the table 'clients name'.
What I have now, is user only able to select a name from combo box but not add unless they exit form and add to table.
Can't seem to figure this one out.
Thanks!
'It is a rather unorthodox approach, but if you are still interested this will
'definately work. Crerate a Command Button next to the Combo Box and
'duplicate this code in the Click() Event: - Private Sub cmdAddNameToComboBox_Click()
-
On Error GoTo Err_cmdAddNameToComboBox_Click
-
-
Dim strNameToAdd As String
-
-
strNameToAdd = InputBox$("Name to Add", "Add Name To Combo Box")
-
If Len(strNameToAdd) > 0 Then
-
Dim MyDB As DAO.Database, MyRS As DAO.Recordset
-
Set MyDB = CurrentDb()
-
Set MyRS = MyDB.OpenRecordset("Client Names", dbOpenDynaset)
-
MyRS.AddNew
-
MyRS![Name] = strNameToAdd
-
MyRS.Update
-
MyRS.Close
-
End If
-
-
Me![cboName].Requery
-
-
Exit_cmdAddNameToComboBox_Click:
-
Exit Sub
-
-
Err_cmdAddNameToComboBox_Click:
-
MsgBox Err.Description, vbExclamation, "Error in cmdAddNameToComboBox()"
-
Resume Exit_cmdAddNameToComboBox_Click
-
End Sub
NOTE: Should you need any further clarification, please let me know...
1. Create a cmdAdd button next to the combo box.
2. Make a AddAClient Form (Pop up form) so that user can add a new client. At the bottom of the form, create a cmdSave button and a cmdCancel button. Whent he user click on the cmdAdd button, it should open the form AddAClient Form. After the user enter the data, when the user click on the cmdSave button, it should save to your Client table. Make sure to put code on all your cmd button.
3. In the combox box, After Update command, but code comboboxName.Requery.
It should update your combo box.
good luck!
'It is a rather unorthodox approach, but if you are still interested this will
'definately work. Crerate a Command Button next to the Combo Box and
'duplicate this code in the Click() Event: - Private Sub cmdAddNameToComboBox_Click()
-
On Error GoTo Err_cmdAddNameToComboBox_Click
-
-
Dim strNameToAdd As String
-
-
strNameToAdd = InputBox$("Name to Add", "Add Name To Combo Box")
-
If Len(strNameToAdd) > 0 Then
-
Dim MyDB As DAO.Database, MyRS As DAO.Recordset
-
Set MyDB = CurrentDb()
-
Set MyRS = MyDB.OpenRecordset("Client Names", dbOpenDynaset)
-
MyRS.AddNew
-
MyRS![Name] = strNameToAdd
-
MyRS.Update
-
MyRS.Close
-
End If
-
-
Me![cboName].Requery
-
-
Exit_cmdAddNameToComboBox_Click:
-
Exit Sub
-
-
Err_cmdAddNameToComboBox_Click:
-
MsgBox Err.Description, vbExclamation, "Error in cmdAddNameToComboBox()"
-
Resume Exit_cmdAddNameToComboBox_Click
-
End Sub
NOTE: Should you need any further clarification, please let me know...
Thanks for your reply. Being new to Access, I'm not sure what the code means. So when I did type in new name it gives me an error message that says "item not found in this collection". Did not add to Combo box or table.
Combo boxes also have an "on not in list" event that the above suggested technique can be used in.
NeoPa 32,556
Expert Mod 16PB
Combo boxes also have an "on not in list" event that the above suggested technique can be used in.
That's interesting. I didn't know that.
Thanks for the suggestions, will give them all a try and see which works best for the form.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: MARK |
last post by:
Hi,
I have a printer consumables database.
I have a form designed to change the status of consumables ie. in use,
dead, stock etc.
I select one of my consumables records from the combo box...
|
by: Colin |
last post by:
I have a query that calculates the selling price of products on
customer orders. Selling prices are calculated based on the average
cost of the items when purchased.
As I make new purchases, the...
|
by: N. Graves |
last post by:
I have not been successful with updating a query for a sub form of a
tab control of a sub form of a form.
Basically I have a form that has a combo box to select an equipment
record and on this...
|
by: J. Yuan |
last post by:
Hi,
I am working on a checkout/inventory system. How can I make a button
that when pressed, would update the previous fields transaction number
to a table (for example, -3 printers, so that...
|
by: sara |
last post by:
Hi
I'm pretty new to Access here (using Access 2000), and appreciate the
help and instruction.
I gave myself 2.5 hours to research online and help and try to get this
one, and I am not getting...
|
by: Cndla |
last post by:
hi,
I have two combo boxes in a form. Functionality is such that selecting a value from the first combo box changes the value in the second combo box. Now this works fine in a normal computer with...
|
by: froglog |
last post by:
I have created a MS access DB to track transport costs for tax purposes.
I enter data into a main form that tracks miles traveled by date with a subform . The subform has fields for the date...
|
by: CCLeasing |
last post by:
Hello, I have searched google but can not find a straight forward
answer to my problem. Hopefuly someone will be kind enough to offer
their expertise. Please forgive if this seems a bit convoluted...
|
by: CCLeasing |
last post by:
Hello, I have searched google but can not find a straight forward
answer to my problem. Hopefuly someone will be kind enough to offer
their expertise. Please forgive if this seems a bit convoluted...
|
by: Marianne160 |
last post by:
Hi,
I know there are various answers to this problem available on the web but none of them seem to work for me. I am using Access 2003 to make a form to look up data from a table. I have so far...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |