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 / December 2007

Tip: Looking for answers? Try searching our database.

Auto load fields in form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cjfazio - 29 Dec 2007 23:49 GMT
I have a form where users enter multiple records at a time.  To save time and
to ensure no mistakes are made, I would like to be able to auto populate some
fields such as the users name, report name, and report number.  Is there a
way for users to enter these fields once have them auto populate for each
record they complete.
Linq Adams - 30 Dec 2007 02:46 GMT
You can do this by using the AfterUpdate event of the field you want to carry
forward. This will automatically carry forward to each ensuing new record
until

You edit the field, after which the new value will be carried forward

You close the form

The exact syntax varies depending on the datatype of the field.

For Text fields

Private Sub YourTextControlName_AfterUpdate()
If Not IsNull(Me.YourTextControlName.Value) Then
 YourTextControlName.DefaultValue = """" & Me.YourTextControlName.Value &
""""
End If
End Sub

For Numeric fields

Private Sub YourNumericControlName_AfterUpdate()
If Not IsNull(Me.YourNumericControlName.Value) Then
 YourNumericControlName.DefaultValue = Me.YourNumericControlName.Value
End If
End Sub

For Date fields

Private Sub YourDateControlName_AfterUpdate()
If Not IsNull(Me.YourDateControlName.Value) Then
 YourDateControlName.DefaultValue ="#" &  Me.YourDateControlName & "#"
End If
End Sub

Good luck!

Linq

Signature

There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

cjfazio - 31 Dec 2007 05:05 GMT
Ling,

It sounds like what you suggest should meet my needs but I am having a bit
of trouble implementing the event.  For a text box I have with a name and
control source called CardNoInitiated1, I tried the following:

Private Sub CardNoInitiated1_AfterUpdate()
If Not IsNull(Me.CardNoInitiated1.Value) Then
CardNoInitiated1.DefaultValue = """" & Me.CardNoInitiated1.Value &
""""
End If
End Sub

However the part:

CardNoInitiated1.DefaultValue = """" & Me.CardNoInitiated1.Value &
""""

gave me a compile error of Expected: Expression.

Any thoughts? I am new to VB.

> You can do this by using the AfterUpdate event of the field you want to carry
> forward. This will automatically carry forward to each ensuing new record
[quoted text clipped - 34 lines]
>
> Linq
cjfazio - 31 Dec 2007 05:16 GMT
Linq,

One other question.  If I get this script working and I have two people
using the same form but inputting different records what will be the impact
to the populated fields?  Will the second person that opened the form see the
populated fields that were entered by the first person?

Chuck

> Ling,
>
[quoted text clipped - 56 lines]
> >
> > Linq
cjfazio - 31 Dec 2007 05:49 GMT
Linq,

Forget my questions above.  When I cut and pasted your code it added a
paragraph mark after the """", thus giving me a syntax error.  After I fix
that it worked fine.  It's just what I wanted.  Thanks.

Chuck

> Linq,
>
[quoted text clipped - 65 lines]
> > >
> > > Linq
 
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.