473,325 Members | 2,671 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,325 software developers and data experts.

Creating UniquePrimary key in table

Ken
I have a table I am trying to create with a unique Pk
Table fields
JobID---PK
JobDate
I would like to have the primary key be a combination of increment
number starting with 001 and year and month such as 510=5 of year and
10th month
Each month I would like the increment number to reset itself so
november 1 it would start at 511-001 the December would be 512-001
I did this in the form using
Right(Format([Date],"yyyy"),1) & Format([Date],"mm"
but cant see how to do it in a table
any help is extremly appreciated

Nov 13 '05 #1
6 1213
Straight in a table: put your formula as the default value. Likewise,
on your form, if the text box is bound to the field in the table then
set the form's text box as a default. That would automatically update
the table as well.

You can have a form update the field upon an update event via code.
ME.textbox = Right(Format([Date],"yyyy"),1) & Format([Date],"mm"

textbox would be the name of your textbox

Nov 13 '05 #2
Ken

Dean wrote:
Straight in a table: put your formula as the default value. Likewise,
on your form, if the text box is bound to the field in the table then
set the form's text box as a default. That would automatically update
the table as well.

You can have a form update the field upon an update event via code.
ME.textbox = Right(Format([Date],"yyyy"),1) & Format([Date],"mm"

textbox would be the name of your textbox


I tried to put formula in default in table and come up with
Error not reconizng fields in table redid formula so it was
[JobDate] instead of [Date] to no avail.
created Third field [JobNum] to be combination of [JobID]& [JobDate]
also changed [JobID] to autoNumber.
End Result I am lookng for [JobNum] would be Primary Key in Table
Any Help is apprecieated

Nov 13 '05 #3

Default values in a table cannot rely on other fields in the table.
You can do so in the form.

Nov 13 '05 #4
Ken

Dean wrote:
Default values in a table cannot rely on other fields in the table.
You can do so in the form.


Thanks
I can get it to work in form,but still would like this number in a
table as it it the Main Id throughout the db. Everything tracks by this
number
production,shipping,orders and so on

Maybe I need to step back and let this settle in my mind
some times cant see the forest for all the trees

Nov 13 '05 #5
On your form, this calculation is a text box. Therefore, just make it
bound to a field in the table. Look under "data" in the properties of
the form design. And again under the field design.

Nov 13 '05 #6
"Dean" <de**@coveyaccounting.com> wrote in
news:11**********************@f14g2000cwb.googlegr oups.com:

Default values in a table cannot rely on other fields in the
table. You can do so in the form.

This is not exactly right. The truth is Default values in a table
cannot rely on other fields in the same record of the table.
You can set the default value, to call the dlookup() or other
domain functions

Ken, the trick is to not use the date field to create your
expression. Use the date function! The chance of a user creating a
new record within a few milliseconds of midnight is slim.

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: Neil | last post by:
I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back end. I currently have a selections table in the front end file which the users use to make selections of records. The table...
7
by: John Baker | last post by:
Hi: I would like to know how to create a temp DB to store the data in a table while I do something else with the table. Specifically, how do I create the temp remove the temp I want to be...
1
by: Dixie | last post by:
I wish to add some fields to an existing table in code. I am using the following code from rkc. CurrentDb.Execute ("ALTER TABLE MyTable ADD MyNewField Text 25") This works , but I need to also set...
8
by: Nanda | last post by:
hi, I am trying to generate parameters for the updatecommand at runtime. this.oleDbDeleteCommand1.CommandText=cmdtext; this.oleDbDeleteCommand1.Connection =this.oleDbConnection1;...
4
by: Coleen | last post by:
Hi All :-) Can anyone give me a URL where I can find a good example of code on how to create a temporary SQL table using VB.net? I've checked the Microsoft site at: ...
16
by: pukivruki | last post by:
hi, I wish to create a temporary table who's name is dynamic based on the argument. ALTER PROCEDURE . @PID1 VARCHAR(50), @PID2 VARCHAR(50), @TICKET VARCHAR(20)
2
by: astolpho | last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output: ...
2
by: djpaul | last post by:
Hello, I have this program and when i want to load pictures it crashes at the form.showdialog()....??? Here it goes: Private Sub CmbPath_SelectedIndexChanged(ByVal sender As Object, ByVal e As...
6
by: firefighter17103 | last post by:
Hi All, I am new to MS Access 07, & do not know any VB, on a new business adventure. I am running Office07 on Vista Home Premium. I am in the process of creating a database that in the end I...
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.