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

Access Combox Question

P: 1
I have a form with a combox box where the list is populated via a linked table. This works fine. I have a text box that is filled with the name selected in the combox box. That name is then added to another table. That works fine. My problem is this, I want to keep the second table from being populated with the same name. So, for exampe, if I select the name John Smith in the Combo box but John Smith already exist in the second table, I want the process ended and a message to pop stating user already added. Does this make sense?

I'm kind of a vba newbie...so, I need a little help.

Thanks
Dec 21 '07 #1
Share this Question
Share on Google+
1 Reply


missinglinq
Expert 2.5K+
P: 3,532
This is untested but I think it'll do the job! You'll need to change the object names (NameComboBox, SecondTableNameField, YourSecondTable, and NameTextField) to match your own actual names.

Expand|Select|Wrap|Line Numbers
  1. Private Sub NameComboBox_AfterUpdate()
  2. If DCount("[SecondTableNameField]", "YourSecondTable", "[SecondTableNameField]='" & Me![NameComboBox] & "'") < 1 Then
  3.   Me.NameTextField = Me.NameComboBox
  4. Else
  5.   MsgBox "This Name Already Exisits in Second Table! Try again!"
  6. End If
  7. End Sub
  8.  
Welcome to TheScripts!

Linq ;0)>
Dec 21 '07 #2

Post your reply

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