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

Current/System date in Access

Hi All,

I'm making library db using SQL.

I have date when book has been loaned (Date loaned) and date to return the
book (Return date), which is 4 weeks.

How can I get current date to show in Date loaned-field?
How do I add 4 weeks to date loaned and can I do it in INSERT
INTO-sentence?

Thanks,

Miikka

Nov 13 '05 #1
11 10595
Set the Default Value property of your Loaned text box to =Date()

Use the After Update event procedure of the Loaned text box to set the
Return date text box 28 days ahead:

Private Sub Loaded_AfterUpdate()
Me.[Return date] = DateAdd("d", 28, Me.Loaned)
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
Hi All,

I'm making library db using SQL.

I have date when book has been loaned (Date loaned) and date to return the
book (Return date), which is 4 weeks.

How can I get current date to show in Date loaned-field?
How do I add 4 weeks to date loaned and can I do it in INSERT
INTO-sentence?

Thanks,

Miikka

Nov 13 '05 #2
Can I do this with SQL?

"Allen Browne" <Al*********@SeeSig.Invalid> kirjoitti
viestissä:41***********************@per-qv1-newsreader-01.iinet.net.au...
Set the Default Value property of your Loaned text box to =Date()

Use the After Update event procedure of the Loaned text box to set the
Return date text box 28 days ahead:

Private Sub Loaded_AfterUpdate()
Me.[Return date] = DateAdd("d", 28, Me.Loaned)
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
Hi All,

I'm making library db using SQL.

I have date when book has been loaned (Date loaned) and date to return
the book (Return date), which is 4 weeks.

How can I get current date to show in Date loaned-field?
How do I add 4 weeks to date loaned and can I do it in INSERT
INTO-sentence?

Thanks,

Miikka


Nov 13 '05 #3
No. AFAIK, you cannot set the Default Value of a field in an Access table to
a function with a DDL SQL statement.

If you need to set he Return Date to 28 days after the Loaned date for many
existing records at once, you could use an Update query. (Update on Query
menu in query design view.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
Can I do this with SQL?

"Allen Browne" <Al*********@SeeSig.Invalid> kirjoitti
viestissd:41***********************@per-qv1-newsreader-01.iinet.net.au...
Set the Default Value property of your Loaned text box to =Date()

Use the After Update event procedure of the Loaned text box to set the
Return date text box 28 days ahead:

Private Sub Loaded_AfterUpdate()
Me.[Return date] = DateAdd("d", 28, Me.Loaned)
End Sub
"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
Hi All,

I'm making library db using SQL.

I have date when book has been loaned (Date loaned) and date to return
the book (Return date), which is 4 weeks.

How can I get current date to show in Date loaned-field?
How do I add 4 weeks to date loaned and can I do it in INSERT
INTO-sentence?

Thanks,

Miikka

Nov 13 '05 #4
So I have to add the "Date Loaned" by hand.
I have done so and the updated the return date, but it should be automatic
when new book is loaned from db.

Thanks for your answers, I will keep trying :-)

//Miikka

"Allen Browne" <Al*********@SeeSig.Invalid> kirjoitti
viestissä:41***********************@per-qv1-newsreader-01.iinet.net.au...
No. AFAIK, you cannot set the Default Value of a field in an Access table
to a function with a DDL SQL statement.

If you need to set he Return Date to 28 days after the Loaned date for
many existing records at once, you could use an Update query. (Update on
Query menu in query design view.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
Can I do this with SQL?

"Allen Browne" <Al*********@SeeSig.Invalid> kirjoitti
viestissd:41***********************@per-qv1-newsreader-01.iinet.net.au...
Set the Default Value property of your Loaned text box to =Date()

Use the After Update event procedure of the Loaned text box to set the
Return date text box 28 days ahead:

Private Sub Loaded_AfterUpdate()
Me.[Return date] = DateAdd("d", 28, Me.Loaned)
End Sub
"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
Hi All,

I'm making library db using SQL.

I have date when book has been loaned (Date loaned) and date to return
the book (Return date), which is 4 weeks.

How can I get current date to show in Date loaned-field?
How do I add 4 weeks to date loaned and can I do it in INSERT
INTO-sentence?

Thanks,

Miikka


Nov 13 '05 #5
Put the following code in the AfterUpdate event of the textbox where you
enter the borrower's name:
Me!LoanedDate = Date()
Me!ReturnDate = DateAdd("d", 28, Me!LoanedDate)
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
So I have to add the "Date Loaned" by hand.
I have done so and the updated the return date, but it should be automatic
when new book is loaned from db.

Thanks for your answers, I will keep trying :-)

//Miikka

"Allen Browne" <Al*********@SeeSig.Invalid> kirjoitti
viestissä:41***********************@per-qv1-newsreader-01.iinet.net.au...
No. AFAIK, you cannot set the Default Value of a field in an Access table to a function with a DDL SQL statement.

If you need to set he Return Date to 28 days after the Loaned date for
many existing records at once, you could use an Update query. (Update on
Query menu in query design view.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
Can I do this with SQL?

"Allen Browne" <Al*********@SeeSig.Invalid> kirjoitti
viestissd:41***********************@per-qv1-newsreader-01.iinet.net.au... Set the Default Value property of your Loaned text box to =Date()

Use the After Update event procedure of the Loaned text box to set the
Return date text box 28 days ahead:

Private Sub Loaded_AfterUpdate()
Me.[Return date] = DateAdd("d", 28, Me.Loaned)
End Sub
"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
> Hi All,
>
> I'm making library db using SQL.
>
> I have date when book has been loaned (Date loaned) and date to return> the book (Return date), which is 4 weeks.
>
> How can I get current date to show in Date loaned-field?
> How do I add 4 weeks to date loaned and can I do it in INSERT
> INTO-sentence?
>
> Thanks,
>
> Miikka



Nov 13 '05 #6
If you look in the properties for Date Loaned field you will see a
default value. All you need to do is add Date() to that value. Then
it is pretty much automatic.

I use a double click function to load the date on one of my forms. it
updates the second date once you leave the field this way.

Private Sub Loaned_Date_DblClick(Cancel As Integer)

If IsNull(Me.Loaned_Date) Then
Exit Sub
End If

Me.Loaned_Date = Date

End Sub

Private Sub Loaned_Date_Exit(Cancel As Integer)

Me.[Return date] = DateAdd("d", 28, Me.Loaned_Date)

End Sub

Of course you could just put it all in a button to make it do this.
Then you just have to click the button to add all of it automatically
and still have the option of changing it manually if you want.

Nov 13 '05 #7
Thank you very much for all info, but is it possible to do these commands in
SQL in Access?

//Miikka

"Miikka Hamalainen" <mi***************@haminetti.net> kirjoitti
viestissä:co**********@phys-news1.kolumbus.fi...
So I have to add the "Date Loaned" by hand.
I have done so and the updated the return date, but it should be automatic
when new book is loaned from db.

Thanks for your answers, I will keep trying :-)

//Miikka

"Allen Browne" <Al*********@SeeSig.Invalid> kirjoitti
viestissä:41***********************@per-qv1-newsreader-01.iinet.net.au...
No. AFAIK, you cannot set the Default Value of a field in an Access table
to a function with a DDL SQL statement.

If you need to set he Return Date to 28 days after the Loaned date for
many existing records at once, you could use an Update query. (Update on
Query menu in query design view.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
Can I do this with SQL?

"Allen Browne" <Al*********@SeeSig.Invalid> kirjoitti
viestissd:41***********************@per-qv1-newsreader-01.iinet.net.au...
Set the Default Value property of your Loaned text box to =Date()

Use the After Update event procedure of the Loaned text box to set the
Return date text box 28 days ahead:

Private Sub Loaded_AfterUpdate()
Me.[Return date] = DateAdd("d", 28, Me.Loaned)
End Sub
"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
> Hi All,
>
> I'm making library db using SQL.
>
> I have date when book has been loaned (Date loaned) and date to return
> the book (Return date), which is 4 weeks.
>
> How can I get current date to show in Date loaned-field?
> How do I add 4 weeks to date loaned and can I do it in INSERT
> INTO-sentence?
>
> Thanks,
>
> Miikka



Nov 13 '05 #8
No! SQL is NOT for adding data. It can only limit data output and modify
data.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
Thank you very much for all info, but is it possible to do these commands in SQL in Access?

//Miikka

"Miikka Hamalainen" <mi***************@haminetti.net> kirjoitti
viestissä:co**********@phys-news1.kolumbus.fi...
So I have to add the "Date Loaned" by hand.
I have done so and the updated the return date, but it should be automatic
when new book is loaned from db.

Thanks for your answers, I will keep trying :-)

//Miikka

"Allen Browne" <Al*********@SeeSig.Invalid> kirjoitti

viestissä:41***********************@per-qv1-newsreader-01.iinet.net.au...
No. AFAIK, you cannot set the Default Value of a field in an Access table to a function with a DDL SQL statement.

If you need to set he Return Date to 28 days after the Loaned date for
many existing records at once, you could use an Update query. (Update on Query menu in query design view.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Miikka Hamalainen" <mi***************@haminetti.net> wrote in message
news:co**********@phys-news1.kolumbus.fi...
Can I do this with SQL?

"Allen Browne" <Al*********@SeeSig.Invalid> kirjoitti
viestissd:41***********************@per-qv1-newsreader-01.iinet.net.au...> Set the Default Value property of your Loaned text box to =Date()
>
> Use the After Update event procedure of the Loaned text box to set the> Return date text box 28 days ahead:
>
> Private Sub Loaded_AfterUpdate()
> Me.[Return date] = DateAdd("d", 28, Me.Loaned)
> End Sub
>
>
> "Miikka Hamalainen" <mi***************@haminetti.net> wrote in message> news:co**********@phys-news1.kolumbus.fi...
>> Hi All,
>>
>> I'm making library db using SQL.
>>
>> I have date when book has been loaned (Date loaned) and date to return>> the book (Return date), which is 4 weeks.
>>
>> How can I get current date to show in Date loaned-field?
>> How do I add 4 weeks to date loaned and can I do it in INSERT
>> INTO-sentence?
>>
>> Thanks,
>>
>> Miikka



Nov 13 '05 #9
PC Datasheet wrote:
No! SQL is NOT for adding data. It can only limit data output and modify
data.


Beg your pardon? What is the SQL INSERT statement doing, then?

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #10
Miikka Hamalainen wrote:
Hi All,

I'm making library db using SQL.

I have date when book has been loaned (Date loaned) and date to return the
book (Return date), which is 4 weeks.

How can I get current date to show in Date loaned-field?
How do I add 4 weeks to date loaned and can I do it in INSERT
INTO-sentence?


If Date() [the current date] is not recognized as a valid function when
you execute the INSERT INTO, you have to pass it as a parameter. You can
use its value+28 for [return date] then.

Could it be that simple?

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #11
Why is it imperative that you must us an SQL command to add this to
your fields?

I would think that having a form with the option to change the value
would be better.

If you really must have a SQL Statement you could just do something
like:

Private Sub Loaned_Date_DblClick(Cancel As Integer)

If IsNull(Me.Loaned_Date) Then
Exit Sub
End If

Me.Loaned_Date = Date
Me.Refresh

$returnDate = = DateAdd("d", 28, Me.Loaned_Date)

DoCmd.RunSQL "UPDATE myTable SET returnDate = '" & $returnDate & "'
WHERE LoanId = '" & $loanId & "';"

End Sub

Nov 13 '05 #12

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

Similar topics

5
by: Larry R Harrison Jr | last post by:
I use the Lebans calendar control and love it; the only thing is that it commonly starts out at the year 1899 rather than the current year. Is there a way to specifically tell it to start at the...
14
by: deko | last post by:
This runs, but does not narrow to current week. suggestions appreciated! SELECT lngEid, dtmApptDate, Subject, Appt_ID FROM qry002 WHERE (dtmApptDate BETWEEN DateAdd("d",-weekday()+2,) And...
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
1
by: Ray Valenti | last post by:
Saving the current date to an Access Database returns an error. this.dsMain1.Tables.Rows= DateTime.Today.ToString(); this.oleDbDataAdapter1.Update(this.dsMain1,"Links"); Tried several formats,...
3
by: Mark Ingram | last post by:
Hi, I'd like to know the best way of checking the current time during a demonstration product. At the minute i store the first run date, then compare that to the system time, but obviously a user...
5
by: Jimmy | last post by:
How do I set the default value of a text box (date/time) to 1/1/Current Year... i.e 1/1/2006 this year, 1/1/2007 next year?
0
by: remya1000 | last post by:
I need to display current month,last 3months,6months and 1year records seperatly. and first i'm tring to display current month's records. and the error i received is this. Microsoft VBScript...
23
by: dhtmlkitchen | last post by:
JSON We all know what it is. In ECMAScript 4, there's a JSON proposal: Object.prototype.toJSONString String.prototype.parseJSON The current proposal, String.prototype.parseJSON, returns...
2
MattFitzgerald
by: MattFitzgerald | last post by:
Hi hope some one can help I have 2 questions:- Question 1) When saving a file in access to excel how do I specify current date Question2) When saving a file in access to excel how do I specify...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.