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 » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

User defined default values for form fields?



 
 
Thread Tools Display Modes
  #1  
Old April 18th, 2008, 08:55 PM posted to microsoft.public.access.forms
jessi
external usenet poster
 
Posts: 23
Default User defined default values for form fields?

I would like to create a form used to input data into a table. The table
structure is shown below:

tbl:Mass1_Rock
StationID (fk)
SampleID (pk)
Mass1
Personnel (fk)
Comments

When the user enters data into the form, they will be entering data for one
station and personnel at a time. Stated another way, they will be entering
all of the mass data for station "6" that was measured by personnel "Dave" at
one time.

In the form I could set the default value for StationID to "6" and the
default value for personnel to "Dave". However, I was wondering if there is
a way to create a dialog box that pops up when the form loads where the user
can choose the default values from the StationID and the Personnel fields
each time they open the form to input data.

I probably haven't stated this question very well, but I'm not certain what
the correct terminology is for what I'm asking.

Regards,
  #2  
Old April 18th, 2008, 09:29 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default User defined default values for form fields?

You don't need a popup form, just have the user enter the first new record as
usual, then you can use the AfterUpdate event of the control holding your
data to set the DefaultValue for the field. From that time forward, until you
either manually change the data or close your form, the data will be entered
automatically in each new record. The syntax is slightly different, depending
on the datatype of the data:


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

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

Answers/posts based on Access 2000/2003

Message posted via http://www.accessmonster.com

  #3  
Old April 18th, 2008, 09:40 PM posted to microsoft.public.access.forms
jessi
external usenet poster
 
Posts: 23
Default User defined default values for form fields?

Thanks! I came across this in some of my searching, but I didn't really get
it until I read your response. This is what I need. Thanks for sending
along an example of the code too.

Jessi

"Linq Adams via AccessMonster.com" wrote:

You don't need a popup form, just have the user enter the first new record as
usual, then you can use the AfterUpdate event of the control holding your
data to set the DefaultValue for the field. From that time forward, until you
either manually change the data or close your form, the data will be entered
automatically in each new record. The syntax is slightly different, depending
on the datatype of the data:


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

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

Answers/posts based on Access 2000/2003

Message posted via http://www.accessmonster.com


 




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


All times are GMT +1. The time now is 04:53 PM.


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