Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / February 2005

Tip: Looking for answers? Try searching our database.

Using After Update to set Default Value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Renee - 02 Feb 2005 15:33 GMT
Good Morning,
  I want to use the currently entered value to prefill the next new record.
On the afterupdate event of the Text box formatted as ShortDate I have the
following code:
If (Not IsNull(Me.EventDate)) Then
   Me.EventDate.DefaultValue = Me.EventDate
End If
I have also tried:
If (Not IsNull(Me.EventDate)) Then
   Me.EventDate.DefaultValue = """" & Me.EventCallDate & """"
End If
Either way, I get the following result:
Enter 2/1/2005, go to a new record, and the value shows as 12/30/1899

On a combo box, I was unsuccessfully trying to do the same thing with the
employee ID:
If (Not IsNull(Me.ID)) Then
   Me.ID.DefaultValue = Me.ID
End If
I have also tried this version with the quotes and ampersands. Both result
in a blank value when I go to a new record.
I would appreciate any support :)

Thanks in advance
JP - 02 Feb 2005 18:42 GMT
On the date field problem, is the control source for the EventDate field
defined as a date type in the underlying table?

If so, then you have to put the # sign date delimiter around the value that
you're sticking into the default value.  That way, the underlying table
field sees a date and is happy.  Otherwise, it just sees a string that is
cannot interpret as a date, and gives you the 12/30/1899 value.

To do this, you code should read:

Me.EventDate.DefaultValue = "#" & Me.EventDate & "#"

This is the way to specify a date in a string

What type of table field is the control source for your ID field in the
second question?  Also, what is the list source for your combo box and do
you have Limit To List = yes?

> Good Morning,
>    I want to use the currently entered value to prefill the next new record.
[quoted text clipped - 20 lines]
>
> Thanks in advance
Renee - 02 Feb 2005 19:35 GMT
The table and form are date data types, changing the """" to "#" worked
wonderfully except for one issue. Both the table and the form do not have a
default value for this date field. The default value is only added on the
after update event. The form is set to data entry true. When I open the form,
it now defaults to 12/30/1899. After I add a new record, the entered date
will prefill the next new record perfectly. How to a fix the opening value?

The datatype of the source table for the ID is text, and the combo box is
set to limit to the list.

Thank you again for your Support JP :)

Renee

> On the date field problem, is the control source for the EventDate field
> defined as a date type in the underlying table?
[quoted text clipped - 39 lines]
> >
> > Thanks in advance
JP - 02 Feb 2005 21:38 GMT
Renee,

Check and make sure that there is no default value in the default value
property field of the form -- it may have picked up a permanent default
value along the way.

Also, you could just assign a default value in the form open event.  For
example, you could put in a line that says

Me.EventDate.DefaultValue = now()

The Now function returns the current date.  I'm not sure if you would have
to put the # around it, so try it both ways.

> The table and form are date data types, changing the """" to "#" worked
> wonderfully except for one issue. Both the table and the form do not have a
[quoted text clipped - 53 lines]
> > >
> > > Thanks in advance
Renee - 03 Feb 2005 17:33 GMT
I added a default value as today's date, and on the form close event reset
the any default values that changed during form use.
Thank you for your help JP!

> Renee,
>
[quoted text clipped - 76 lines]
> > > >
> > > > Thanks in advance
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.