Repetitive data entry

P

Philip Richardson

Using Access 2000 I have a database used as an attendance register for short
courses. There are three tables - one for student details, one for course
details and an attendance register which uses combo boxes to look up student
names and course titles.

If I create a form or a query for data entry, is there a way to make the
course title and date automatically repeat so I only have to enter the
student name?
 
J

Jeanette Cunningham

Using a form, you can make use of the default value of controls.

Using code like that shown below, after enters a value for both course and
date, you can set the default value for both these controls.
While the form is open, user inputs the values for course and date, when
they go to the next row, the defaults are already showing.
Once user closes the form, the defaults won't show until both course and
date have been input, then the defaults will show for the next row.


'code samples --------------
Private Sub controlname_AfterUpdate()
'text field
Me.TheTextControl.DefaultValue = """" & Me. TheTextControl & """"

'date field
Me.TheDateControl.DefaultValue = "#" & Me.TheDateControl & "#"

'number field
Me.TheNumberField.DefaultValue = Me.TheNumberField
End Sub



Because the DefaultValue property is is a string that will be evaluated as
an expression when it is applied to a new record, you need to enclose the
value in quotes so Access can understand what you want it to do:

Me.AssignedChap.DefaultValue = """" & Me.AssignedChap & """"

While that is not strictly required for numeric values (e.g. 12345), it is
still a good idea.

For date values, because a machine's regional date format setting can be
almost anything, you should format the datevalue to an unambiguous style to
make sure Access interprets it the way you intended. E.g.

Me.AssignedChap.DefaultValue = Format(Me.AssignedChap, "\#yyyy-m-d\#")



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top