473,385 Members | 1,769 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,385 software developers and data experts.

Default value of a record equal to previous record in date format

isben22
13
I had a resource for this in the past but lost it somewhere...

I have a need to enter daily information. Every day has to be accounted for, 24/7.

I would like to make the default value of the date record, sequential; i.e. each new record is +1 day of the record before it.

I know I cannot refference a record in the same table, but I cannot seem to find the reference on how to build the query.

Anyone have a reference for this?
May 7 '07 #1
9 4662
puppydogbuddy
1,923 Expert 1GB
See this link:

http://forums.mysql.com/read.php?65,...026#msg-148026

replace the fields used in the example with your fields.
May 7 '07 #2
isben22
13
See this link:

http://forums.mysql.com/read.php?65,...026#msg-148026

replace the fields used in the example with your fields.

Sorry. New to the posting world. I should have specified that I am working with MS Access 2003.

This has led me to the idea of using a form to add a date to the default value but returned an error.

I used this line (from the help file) to try and return a default value:
=DMax([ID],[Date],+1)

But came up with the #Error.

Where should I go?
May 7 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Sorry. New to the posting world. I should have specified that I am working with MS Access 2003.

This has led me to the idea of using a form to add a date to the default value but returned an error.

I used this line (from the help file) to try and return a default value:
=DMax([ID],[Date],+1)

But came up with the #Error.

Where should I go?
You want ...

=DMax("[Date]","TableName")+1
May 7 '07 #4
puppydogbuddy
1,923 Expert 1GB
The syntax provided in the link I gave you is correct even though it is in a MySql forum.

As instructed, you should put your date autonumber expression in the before insert event of the form as shown:.For purposes of illustration, I have named the textbox on your form txtAutoDate, and named the underlying field in your table as fldAutoDate. Me.RecordSource refers to the query that is the data source of your form.

The expression shown below should generate unique sequential numbers. Logically, however, what you are trying to do does not make sense because if you have two transactions on the same day, they will be assigned different date autonumbers. I don't understand why you don't want to use a date and time stamp as your autonumber.


Private Sub YourFormName_BeforeInsert()
Me!txtAutoDate = DMax("[fldAutoDate]", Me.RecordSource) + 1)
End Sub
May 7 '07 #5
isben22
13
You want ...

=DMax("[Date]","TableName")+1

Getting there! Ok got it to work without error. I had to add a comumn to the form (not an issue as there will naturally be other columns) But it has an interesting result.

it lists each date twice like:

ID Date
1 2/2/2007
2 3/2/2007
3 3/2/2007
4 4/2/2007 and so on...

what could be causing this doubling? I really only want one day per record. I will then have a sub table to make a list of people assigned to a day...

Thanks again. Could not have gone this far without you!
May 7 '07 #6
JConsulting
603 Expert 512MB
Getting there! Ok got it to work without error. I had to add a comumn to the form (not an issue as there will naturally be other columns) But it has an interesting result.

it lists each date twice like:

ID Date
1 2/2/2007
2 3/2/2007
3 3/2/2007
4 4/2/2007 and so on...

what could be causing this doubling? I really only want one day per record. I will then have a sub table to make a list of people assigned to a day...

Thanks again. Could not have gone this far without you!

I'm thinking a small function in a code module like so

Function GetLastDate() As Date
GetLastDate = DateAdd("d", 1, DMax("date1", "tblTest"))
End Function

then in the default value for that field in the table

=GetLastDate

When new records are added...this date is automatically entered.

J
PS. Hey PDog!
May 7 '07 #7
isben22
13
I'm thinking a small function in a code module like so

Function GetLastDate() As Date
GetLastDate = DateAdd("d", 1, DMax("date1", "tblTest"))
End Function

then in the default value for that field in the table

=GetLastDate

When new records are added...this date is automatically entered.

J
PS. Hey PDog!
PDog,

I understand your question and maybe I am not attacking this logically.

The large scale event is to create a personnel schedual with a running date.
1 APR 2 APR 3APR
John X / Q
Marry X Q /
Jean Q / Q
Larry X X X

It will look like this in the end. For the purposes of the people I work for, the program will need to work just like the form we use or the program will not be used. Silly, but a necessity.

So I thought the easyest way to accomplish this was to create a table that sequentially gives you the dates with a sub table on the duty each person will preform for that day.

We have 20 people all preforming different duties on each day, and there is never a time where a day is left unaccounted for.

Did I start down the wrong path? If you have an easier way to accomplish this I would be delighted to try it! I thought a master table with the dates and sub tables for the person and events would work best... I dunno... Thoughts?

M
May 8 '07 #8
isben22
13
PDog,

I understand your question and maybe I am not attacking this logically.

The large scale event is to create a personnel schedual with a running date.
1 APR 2 APR 3APR
John X / Q
Marry X Q /
Jean Q / Q
Larry X X X

It will look like this in the end. For the purposes of the people I work for, the program will need to work just like the form we use or the program will not be used. Silly, but a necessity.

So I thought the easyest way to accomplish this was to create a table that sequentially gives you the dates with a sub table on the duty each person will preform for that day.

We have 20 people all preforming different duties on each day, and there is never a time where a day is left unaccounted for.

Did I start down the wrong path? If you have an easier way to accomplish this I would be delighted to try it! I thought a master table with the dates and sub tables for the person and events would work best... I dunno... Thoughts?

M
All that and the "sample table did not come out as I typed it... should I be clearer?
May 8 '07 #9
puppydogbuddy
1,923 Expert 1GB
If you want track the activities of each person for each date using the date autonumber for the date, that won't work because all 20 people will be assigned different date autonumbers for the same activity date.

There are a number of different ways to design the structure of your tables, but I would not use the date a as an autonumber key for the table. Instead, I would use a meaningless Access generated autonumber for internal system use as the primary key for the table.

In addition, I would have the activity date as separate field that could be part of a combined [employee name] & [activity date] index that you would use in presenting the daily record to your users. That way all 20 users could have the same activity date. And if you don't want them to have to type in the activity date, you can set its default value property to the system date (Date()).
May 8 '07 #10

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

Similar topics

5
by: Derek Cooper | last post by:
I hope you can help me. I posted this in the microsoft sql server newsgroup a few days ago and got no response so I thought I'd try here. If I can provide any clarification I'll be glad to do so....
2
by: Norman Fritag | last post by:
Hi there, On a form I click a tickbox ("display",yes/No) that requires the recordset. =>>Code<<-- Me!PositionClosingDate = Format(Date, "Short Date") ' when was the position closed? Me.Requery...
2
by: David Mitchell | last post by:
I have a multiuser database which VBA to return the current users NT logon. The database has a table which contains the names of all users and a field called bmlogon which holds their NT logon. ...
3
by: Phil | last post by:
Newbie to Access so am having a BIT of difficulty. I am trying to get a field value in a new record to equal the value of the same field of a previous one. For instance, Field1 + Field2 =...
10
by: MLH | last post by:
I have an A97 table with a Yes/No field named TowJob and a form bound to that table. The TowJob control on the form is bound to the same field. It is an option group with Yes and No bttns valued...
7
by: mr.nimz | last post by:
hello, this is antenio. recently i've come to a problem. i got a way through it, somehow, still it left me in a curious state, so i'm posting it here, if i can get an answer from some techy, ...
3
by: Stephen | last post by:
Hi, I have a table consists which cosists of batch numbers, and assosiated dates and times..ie the columns are batch, date and time. The data within the table is not in any particular order. ...
1
by: Wes Brooks | last post by:
Hello expert, Please help me with the following problems. I have spent ages to resolve them but no luck. I have two forms. (1) "Document Reception Input Form" is the main form. The search...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.