Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2002
    Location
    Kansas City
    Posts
    103

    Unanswered: Checking value in form control against a table recordset.


    How would I validate that the value selected in a form control combo box does not exist in a database make table using VBA?

    Do I need to somehow define the table data field first? What I have is a non-starter!


    CurrentDb().TableDefs("Payroll Tax Table").Fields("Payroll Pay Period").DefaultValue = "PPP"

    If Me.Payroll_Pay_Period.Value = "PPP" Then

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    rather than do this in code I'd suggest that you do this as part of your database design. If you are unsure of what realtional databases can do for you then have a look at this

    limit the data in the combo box to that in the list
    -populate the combo box using a select based on the table with the required codes & description
    -set a relationship between the parent table and the child table (Tools | realtionships) such that the code int he child table must exists int he parent table (use Referential Integrity to achieve this. Optionally consider how you want to handle changes to the parent data. Either delete cascade, delete update or both)
    optionally - provide some mechanism whereby a user can rebuild the combox in case new codes are added or old codes deleted whilst thye have the form open

    this would require that you create a new table containing Tax Codes. You may want to specify in this codes tables which is the default code by seting say a IsDefault column for the default codes, alternativel you could set a flag and identify the most popular codes so that these come up forst in combo box

    HTH
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2002
    Location
    Kansas City
    Posts
    103
    Thank you, healdem for your suggestions. It caused me to re-think my approach a bit. I created an "unmatched" query behind my combo box and am able to eliminate duplicate values for a user.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •