Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto-populate ID based on another form field 3

Status
Not open for further replies.

btj

Technical User
Nov 17, 2001
94
US
I have a form that allows users to Add or Edit their records. I have an "Add" button that creates a blank record and a "Replicate" button that replicates all information from the current record, excluding ID.

As my record set increases in size, I have found that I need to have the "ID" field be automatically generated for users (both in new blank and replicated records) because they don't remember the last ID used.

So, is there a way to auto generate the next ID once the ID category is chosen?

Example:
Current record
ID: TC-ACL001
Category: Access Lists Policy - ACL

Replicated record
ID: TC-ACL002 (this would be the auto generated number)
Category: Access Lists Policy - ACL (replicated by code)

New blank record
ID: TC-FW002 (auto-generated because there was only one other test case under Category "FW")
Category: Firewall Policy - FW


Hope this makes sense. I am thoroughly stumped and would appreciate any advice/ideas you may have.

Thank you, in advance.

- Ben

 
Hi Sir Cole,
The easy way actually involves no coding, but it only works when:
- it's in a bound form, where the textboxes you mentioned all need to point to values which are located on the table that is the control source for the form.

For example, if you have a table which includes the following fields:
SerialNo (primary key)
Item Name
Manufacturer

.. and you wanted to pick the serial number and then show just the fields for those three things, you would set the Control Source for the form to that table, and create a new combo box. The wizard appears, and the first window gives you three choices, one of which is "Find a record on my form based on the value I selected in my combo box." Pick that one. Later, when asked if you want to "Remember this value for later use" or "Store that value in this field..", pick "Remember this value for later use."

There is actually code involved; it's just not code you have to write :) (the wizard writes it for you. You can still look at/modify it afterwards just as you would normal code, though).

If I've completely misunderstood your needs, and you actually need more flexibility and/or you have reasons for not doing a bound form, please let us know and I can give you some sample code for doing this in unbound forms.

HTH! Katie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top