By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,124 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

Combo box add new customer

P: 1
I have on a form a combo box that lists all my customers from a customers table.
How do I add a new customer from this combo box? bearing in mind the form only displays the customers.
Feb 23 '07 #1
Share this Question
Share on Google+
4 Replies


JamesDC
P: 66
I have on a form a combo box that lists all my customers from a customers table.
How do I add a new customer from this combo box? bearing in mind the form only displays the customers.
Add a text field somewhere on the form that add new records to the costumer table. That way the combobox will be updated with the new costumer's when they're put into the new field.

I'm not sure if there is a way to do this directly in the combobox...
Feb 23 '07 #2

Rabbit
Expert Mod 10K+
P: 12,324
In the After Update event of the Combo box:
Expand|Select|Wrap|Line Numbers
  1. Private Combo_Box_Name_AfterUpdate()
  2. If DCount("*", "[Customer Table Name]", "[Customer Field Name] = '" & Me.[Combo_Box_Name] & "'") = 0 Then
  3.    If MsgBox("Do You Wish To Add '" & Me.[Combo Box Name] & "' As A New Customer?", vkOKCancel) = vbOK Then
  4.       DoCmd.SetWarnings False
  5.       DoCmd.RunSQL "Insert Into [Customer Table Name] Values ('" & Me.[Combo Box Name] & "')"
  6.       DoCmd.SetWarnings True
  7.    End If
  8. End If
  9. End Sub
Feb 23 '07 #3

NeoPa
Expert Mod 15k+
P: 31,261
Nice solution.
The ComboBox would need the LimitToList property set to False for this to work.
Feb 26 '07 #4

Rabbit
Expert Mod 10K+
P: 12,324
You'll also need to requery the combo box.
Feb 26 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.