A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Using expression builder in default value



 
 
Thread Tools Display Modes
  #1  
Old September 18th, 2004, 07:51 AM
Copwriter
external usenet poster
 
Posts: n/a
Default Using expression builder in default value

I want the default value for a date field (short date format) to have the
same value as another date field. I have tried entering this into
Expression Builder as variations on =[dteStartDate], but it always returns
an error. How do I get the default value in one date field to reflect the
value in another?


  #2  
Old September 19th, 2004, 02:11 PM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default

As I recall, Access won't let you use another field's value as part of an
expression for a Default Value. It makes sense, when you consider that a
Default Value is added to a new record when the record is created, and when
it is created, the "other" field won't have any value?!

But your post begs another question -- if you already have another field
that holds a value, why do you need to store it a second time, as a
"default" value?

--
More info, please ...

Jeff Boyce
Access MVP

  #3  
Old September 20th, 2004, 01:15 AM
Copwriter
external usenet poster
 
Posts: n/a
Default

But your post begs another question -- if you already have another field
that holds a value, why do you need to store it a second time, as a
"default" value?


Thanks for the reply. The database is to hold training records, what
persons attended various classes and when. The two date fields in question
are the start and end dates of each training session. It's anticipated that
most sessions will be only one day in length, so I want the default value
for the dteEndDate to be the same as the entered value for dteStartDate.
However, in case the class being entered does span multiple days, I want the
user to be able to enter a different (later) date for the dteEndDate field.


  #4  
Old September 20th, 2004, 02:44 AM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default

In that case, I'd suggest using a form, rather than the table directly. In
the form, you can add code behind the control in which the start date is
entered, "forcing" the same date into the end date control.

--
Good luck

Jeff Boyce
Access MVP

  #5  
Old September 20th, 2004, 07:04 AM
Copwriter
external usenet poster
 
Posts: n/a
Default

In that case, I'd suggest using a form, rather than the table directly.
In
the form, you can add code behind the control in which the start date is
entered, "forcing" the same date into the end date control.


I'm trying that, but I can't seem to get it right in the form. I'm trying

=[dteStartDate]

in the default value blank for the properties for dteEndDate on the form
that fills in tblClasses, but nothing happens when I put a date into
dteStartDate and then tab into dteEndDate. What am I doing wrong?


  #6  
Old September 20th, 2004, 11:16 AM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default

See my original response AND my second reply. When you start a new record,
via table or form, the first (date) field will have no value.

You are still trying to put a "default" property value in.

My second reply mentioned putting code behind the "start date" control. Use
the AfterUpdate event and, if what is entered into the [Start Date] control
is actually a date (IsDate()), THAT'S when you set the value of the second
date control.

--
Good luck

Jeff Boyce
Access MVP

  #7  
Old September 20th, 2004, 11:50 PM
Copwriter
external usenet poster
 
Posts: n/a
Default

You are still trying to put a "default" property value in.

My second reply mentioned putting code behind the "start date" control.

Use
the AfterUpdate event and, if what is entered into the [Start Date]

control
is actually a date (IsDate()), THAT'S when you set the value of the second
date control.


Am I SOL if I don't know how to code in VBA? I was hoping to use Expression
Builder to set the event because of my deficiency there.


  #8  
Old September 21st, 2004, 01:54 AM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default

Actually, I'd prefer to "spin" it as an opportunity ... and there is VERY
little coding that needs to happen.

If you open the properties window of the [Start Date] control on the form
(in design mode), you can double click on After Update to get an event
procedure. Use the "..." button on the far right of that row to open the
VBA editor.

Within the event procedure, add something like:

Me!txtYourEndDateControlName = Me!txtYourStartDateControlName

This (with your control names inserted properly) will copy whatever is in
your StartDate control into the EndDate control.

--
Good luck

Jeff Boyce
Access MVP

  #9  
Old September 21st, 2004, 09:42 PM
Copwriter
external usenet poster
 
Posts: n/a
Default

That did it! Thanks very much for your help.


"Jeff Boyce" -DISCARD_HYPHEN_TO_END wrote in message
...
Actually, I'd prefer to "spin" it as an opportunity ... and there is VERY
little coding that needs to happen.

If you open the properties window of the [Start Date] control on the form
(in design mode), you can double click on After Update to get an event
procedure. Use the "..." button on the far right of that row to open the
VBA editor.

Within the event procedure, add something like:

Me!txtYourEndDateControlName = Me!txtYourStartDateControlName

This (with your control names inserted properly) will copy whatever is

in
your StartDate control into the EndDate control.

--
Good luck

Jeff Boyce
Access MVP



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Expression Builder [email protected] Setting Up & Running Reports 1 September 11th, 2004 07:51 PM
non-functional Expression Builder Larry Running & Setting Up Queries 0 August 26th, 2004 03:00 PM
Expression Builder Hai Le General Discussion 3 August 13th, 2004 06:06 PM
Default Printer Problems Ella Setting Up & Running Reports 1 June 7th, 2004 12:01 AM
Carriage Returns in Expression Builder Joe Cooke Setting Up & Running Reports 3 May 24th, 2004 03:06 PM


All times are GMT +1. The time now is 03:03 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.