Trouble with making the ID

jscrinc

New member
Local time
Today, 11:40
Joined
Dec 4, 2009
Messages
5
I have a nice little data base set up, and I was making a form for new customers details to be added into the system.
I added simple details such as Name, Address etc.
When the users presses save it goes to a new form where the user need to select what the customer wants (What type of phone they want and how many months they want it for)
But Im having trouble setting it up, for it to save into my database table.
You see the field in the contract table includes: Contract ID, Contract Begin Date, Phone ID, Package Type and Customer ID.
Customer ID, Phone ID and Package Type are all foreign Keys.
The problem Im having is with the Contract ID, I want the form to automatically do this with the layout MDC at the start and four other digits following it but allow plusing one to the last ID.
So say the last ID is MDC1087 the next will need to be MDC1088, How will i make the form automatically fill this in.
Another additional problem Im facing is with the Phone ID, I want my user to choose a phone name, which is present in the Phone Table, but i need it to save it to the contract table as it ID, What I want is when the user select a phone, it will show its phone ID, ready for it to save in my contract table.
 
Since the MCD prefix is constant it should not be stored. Just store the number.
Add the prefix to the control source expression of the textbox on the form.
= "MCD" & [ContractID]

BTW. Drop the spaces from names. They just make unnecessary work having to include everything in brackets manually.

Numbers can be incremented by finding the Max(fieldname) in the footer of the form and adding to it. However this can be a problem in multiuser databases because two operators may be simultaneously adding records.

To get around this the next available number is stored in a table and the value incremented as soon as the new record is initiated in the main tables by the user.

Your combo for selecting the Phone Type should have the properties set to show the name and store the ID.

Row Source: SELECT TypeID, TypeName From sometable ORDER BY TypeName;
Columns: 2
Bound Column: 1
Column Widths: 0cm, 3cm
 

Users who are viewing this thread

Back
Top Bottom