473,323 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Autoinsert Next Available Value From Lookup Table

Hello everyone! I'm new here, so go easy on me ;-) I have a pretty good skillset with VBA for Excel, but now I'm venturing out into Access. So if the solution I'm looking for requires VBA (and I'm sure it will), a little extra TLC would be greatly appreciated.

I have a table (AccessCodes) with three fields: AccessCode (PK), Available(Boolean), and ActivateDate. All AccessCode values are unique. I use this table as a lookup table for my main table which is called "EligibleCustomers".

As each record is added to the EligibleCustomer table, I would like Access to automatically assign the customer the next available AccessCode in the lookup table.

I would imagine that it first start with making a simple SELECT query on the Lookup table with Available = True. The query would then be used to link to EligibleCustomers as its lookup source.

The procedure I'm unsure about is how to automatically assign the next available AccessCode to the customer, and then mark the AccessCode's Availability to False.

Your helps is greatly appeciated. Thanks.
Aug 15 '07 #1
1 1958
FishVal
2,653 Expert 2GB
Hello everyone! I'm new here, so go easy on me ;-) I have a pretty good skillset with VBA for Excel, but now I'm venturing out into Access. So if the solution I'm looking for requires VBA (and I'm sure it will), a little extra TLC would be greatly appreciated.

I have a table (AccessCodes) with three fields: AccessCode (PK), Available(Boolean), and ActivateDate. All AccessCode values are unique. I use this table as a lookup table for my main table which is called "EligibleCustomers".

As each record is added to the EligibleCustomer table, I would like Access to automatically assign the customer the next available AccessCode in the lookup table.

I would imagine that it first start with making a simple SELECT query on the Lookup table with Available = True. The query would then be used to link to EligibleCustomers as its lookup source.

The procedure I'm unsure about is how to automatically assign the next available AccessCode to the customer, and then mark the AccessCode's Availability to False.

Your helps is greatly appeciated. Thanks.
Hi, there.

The particular solution strongly depends on your interface. But as avery basic example I could sugget you the following
Expand|Select|Wrap|Line Numbers
  1.     Dim lngAccessCode As Long
  2.  
  3.     lngAccessCode = DLookup("[AccessCode]", "[AccessCodes]", "Available=True")
  4.     With DoCmd
  5.         .SetWarnings False
  6.         .RunSQL "UPDATE AccessCodes SET AccessCodes.Available = False " & _
  7.             "WHERE AccessCodes.AccessCode = " & lngAccessCode & ";"
  8.         .SetWarnings True
  9.     End With
  10.  
Aug 15 '07 #2

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

Similar topics

0
by: northshore | last post by:
Hello, I am creating a windows application database. I have a primary table 'Individuals' and a lookup table 'Prefixes.' In the Individuals table, I have a column 'PrefixID' that references...
5
by: sensreview | last post by:
Hello, I need help in selecting a value from combo list thru one lookup table and update different table on MS access form. For eg; I have a lookup table of usernames, I need to use this...
1
by: Tony Dunn | last post by:
I have inherited another developer's database (Access 2003) and with it a problem I'm struggling with. The problem is this. I have a parent-child form pair, which is populated by a table (the...
2
by: tasmontique | last post by:
I am working on an access 2002 flight schedule database. I am new to access but have some basic understanding of sql and vb6 code. I have learned a lot from this website. Thanks much Hopefully...
0
by: Andrus | last post by:
I tried to use modeless picklist for DataGridView custom ComboBoxColumn without success. Steps to reproduce issue: 1. Run code 2. Enter some character 3. Press Tab Observed:
0
by: elainenguyen | last post by:
I am writting an address book which store name and address. I've written a Node class with Get and Set method of String key and String value I've also written a Main class for the menu to promt...
4
osward
by: osward | last post by:
I had made a table colum sortable and paging the table, following are the code // Display Event List echo "<center>"._EVENTLIST."</center><br>"; $now = Date(Y-m-d); // sort table...
7
by: samdev | last post by:
I have set up a table with a few fields that are set to required....all work fine except the fields that are Lookup from another table. What am I forgetting to set? Thanks!!
7
by: Chad | last post by:
On pages 144 to 145 in the book "The C Programming Language" by K & R, they have part of the following #define HASHSIZE 101 static struct nlist *hastab; struct nlist *lookup(char *s) {...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.