Using this string in forms control source "=DateSerial(year([StartDate]), month([StartDate])+6, day([StartDate]))". Works correctly in the the form, but does not update the fields in the table. New to Access -- any help would be appreciated. Thanks in advance.
24 4547
Using this string in forms control source "=DateSerial(year([StartDate]), month([StartDate])+6, day([StartDate]))". Works correctly in the the form, but does not update the fields in the table. New to Access -- any help would be appreciated. Thanks in advance.
By putting that in a textboxes control source you are not storing it anywhere. The control source should be set to the field. Put the calculation in the default value and it will set the field to the correct value when the form opens.
Thanks for the quick reply - I will try that this morning and let you know how it turns out.
Mac, Tried entering the string into the default value box -- still no change/update to the table fields. I must have a bracket upside down or something. I'll keep working with it. Think of any other suggestions please let me know.
Mac, Tried entering the string into the default value box -- still no change/update to the table fields. I must have a bracket upside down or something. I'll keep working with it. Think of any other suggestions please let me know.
Did you also set the control source to the appropriate field?
This default value will only trigger when you open the form to the appropriate record.
The control source is set to the default field where I'm adding the string to the default value. Should it be set to another field? Thanks for your patience.
The control source is set to the default field where I'm adding the string to the default value. Should it be set to another field? Thanks for your patience.
I don't really understand what you're saying.
Set the Control Source to the field in the table or query that you want to store the value in and set the default value to the previously mentioned statement. These are two separate properties.
Mac, I created a form using the info listed below from a Microsoft site. I changed the control source value for "futuredate" to futuredate. Also added the DatesSerial string to the default value as you prescribe. I can't figure out what I'm doing wrong. Again thanks for your help.
(Microsoft Site) ---- In Access, you can calculate a future or past date from a starting date by using an expression. For example, you can enter a date in a control on a form and calculate a date that is six months in the future from the original date. This article demonstrates this technique by using the DateSerial function to calculate the future date in the controls on a form. The calculated date can then be used in other calculations.
To calculate a future date by using the DateSerial function
In the Database window, click Forms under Objects, and then click New.
In the New Form dialog box, click Design View, and then click OK.
Using the Text Box tool in the toolbox, add two unbound text boxes to your form.
Set the Name property for one text box to StartDate and the other to FutureDate.
Set the Format property for the StartDate text box to Short Date.
Set the Control Source property for the FutureDate text box to the following expression: =DateSerial(year([StartDate]), month([StartDate])+6, day([StartDate]))
Switch to Form view.
In the StartDate text box, type a date (mm/dd/yy), and then press the TAB key.
The value displayed in the FutureDate text box is six months after the date in the StartDate text box.
Inserting a plus (+) followed by a number after the year, month, or day in the appropriate part of the function calculates a date that number of units in the future. Inserting a minus (-) followed by a number in the appropriate part of the function calculates a date that number of units in the past.
(Microsoft Site) ---- In Access, you can calculate a future or past date from a starting date by using an expression. For example, you can enter a date in a control on a form and calculate a date that is six months in the future from the original date. This article demonstrates this technique by using the DateSerial function to calculate the future date in the controls on a form. The calculated date can then be used in other calculations.
To calculate a future date by using the DateSerial function
In the Database window, click Forms under Objects, and then click New.
In the New Form dialog box, click Design View, and then click OK.
Using the Text Box tool in the toolbox, add two unbound text boxes to your form.
Set the Name property for one text box to StartDate and the other to FutureDate.
Set the Format property for the StartDate text box to Short Date.
Set the Control Source property for the FutureDate text box to the following expression: =DateSerial(year([StartDate]), month([StartDate])+6, day([StartDate]))
Switch to Form view.
In the StartDate text box, type a date (mm/dd/yy), and then press the TAB key.
The value displayed in the FutureDate text box is six months after the date in the StartDate text box.
Inserting a plus (+) followed by a number after the year, month, or day in the appropriate part of the function calculates a date that number of units in the future. Inserting a minus (-) followed by a number in the appropriate part of the function calculates a date that number of units in the past.
What you have here will work fine but it doesn't store the FutureDate anywhere.
Mac, I created a form using the info listed below from a Microsoft site. I changed the control source value for "futuredate" to futuredate. Also added the DatesSerial string to the default value as you prescribe. I can't figure out what I'm doing wrong. Again thanks for your help.
What is showing in the FutureDate textbox. Is it the correct value?
FutureDate Textbox has "Futuredate".
FutureDate Textbox has "Futuredate".
OK, open the properties window for the FutureDate textbox and click the dropdown box beside the Control Source property. Is futuredate a field on the list?
Yes, and I have it as the selected field
Yes, and I have it as the selected field
Then I don't understand why the value is not being stored in the field. If you close the form and open the table to the same record is the value still not stored there?
Yes, after closing the form, the table field for "Futuredate" has not been updated/changed, in fact it is blank. Table field for "StartDate"is doing what it is suppose to do. Still baffled by this somewhat simple procedure.
So the calculated value of futuredate shows on the form but doesn't get stored in the table?
Mary
Yes, that is correct. I have just about given up on this. Can't figure out what the problem could be. I have deleted the database and created new, just to see if that made a difference. The current (test) database at this point only has the table and form for three fields -- ID, Startdate, and Futuredate. Dave
Yes, that is correct. I have just about given up on this. Can't figure out what the problem could be. I have deleted the database and created new, just to see if that made a difference. The current (test) database at this point only has the table and form for three fields -- ID, Startdate, and Futuredate. Dave
Can you try to attach the test database to your last post Dave. If you click the Edit/Delete link it should give you the option.
Mary
BTW, post a reply once it's done so I'll know.
Mary - here's the "Test" database -- good luck -- Dave
Well I'll try it again with a zip file.
Well I'll try it again with a zip file.
What version of Access are you using and why have you got an accdb extension on the file.
Mary
That would be 2007 Beta -- free trial and download -- had the same problem with version 2000 that I was using previuosly. I guess Microsoft has gone to a new extension for the databases.
That would be 2007 Beta -- free trial and download -- had the same problem with version 2000 that I was using previuosly. I guess Microsoft has gone to a new extension for the databases.
OK, I haven't gotten that version so can't open the file. Can you try to convert the database to previous version. Normally an option under the Tools menu probably in Utilities.
OK Dave the default value will only work with new records not on existing ones. I've removed the code from there and added to simple vba event procedures one of which will run if the start date is changed or a new startdate is added and the other of which will run when the form record is opened which will work for all existing records.
Mary
Thanks Mary, When I opened the rev database in 2007 -- it didn't show the form ob ject -- only the table. I will try it in another computer with earlier version of Access. Thanks again, Dave
Sign in to post your reply or Sign up for a free account.
Similar topics
by: cwbp17 |
last post by:
Have two tables that have a FK relationship on ID column.
Have one datagrid that displays all of the columns of both tables.
What's the best approach on updating a row from the datagrid back to...
|
by: Mark Lees |
last post by:
I've built a simple DB and I'm having my users test it at a different
location running on a single workstation. Mean while I'm making
changes to the forms and reports on my workstation. How do I...
|
by: RC |
last post by:
I am updating/improving a working database for a non-profit
organization. I am thinking of making a copy of the database at the
office, bringing the copy to my house, making the changes and then...
|
by: James Fortune |
last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't
understand why people who know how to write code to completely replace
a front end do not write something that will automate...
|
by: Joey Powell |
last post by:
Hello all. For a long time now I have been struggling with a .net
Windows Forms problem. In several of my applications, I use the
"Process" class from System.Diagnostics to accomplish various task...
|
by: James |
last post by:
I have a VB windows forms application that accesses a Microsoft Access
database that has been secured using user-level security. The
application is being deployed using No-Touch deployment. The...
|
by: James |
last post by:
I have a VB windows forms application that accesses a Microsoft Access
database that has been secured using user-level security. The
application is being deployed using No-Touch deployment. The...
|
by: Geoff |
last post by:
Hi
I'm hoping somebody can help me with the following problem that has occurred
to me.
Suppose I have two tables in an SQL Server database. Let's call these tables
A and B. Assume that A has...
|
by: elaina |
last post by:
Hi all.
I am a complete newbie to Access. I've created a set of forms with nested subforms which while lovely (Yay me), are completely non-functional (boo).
There seem to be 2 problems, but I...
|
by: Luting |
last post by:
Hi,
Is it possible to update oracle via Access forms?
I am thinking maybe I could make a link table connnected with oracle
database. And the form could be based on the link table. Does this...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |