Automatically populating a field

  • Thread starter Thread starter Jerry Crosby
  • Start date Start date
J

Jerry Crosby

I have a database containing student registration
information for multiple event sessions. For sake of
discussion, I'll just mention two, namely Spring and
Fall. To register a student, an opening screen
asks, "What session do you want to work with, Spring or
Fall?"

When the appropriate session is chosen, the next screen is
a blank registration form, ready for data. One of the
fields in the table behind the form is a key (number) that
links it to the appropriate event session (spring or fall).

What I'd like to have happen is to automatically "fill in"
that field with the session key. It seems redundant to
first ask, "what session do you want to work with?" and
then ask again, "what session do you want this student
in?" (I can envision users screaming, "I've already told
you what session.!")

Simple fix?

Thanks in advance.

Jerry
 
Hi Jerry,

You can use the OpenArgs parmeter of docmd.openform to pass a starting value
to the registration form. Then use the Open or Load event of the
Registration form to set the default value of the SessionId control:

Initial Form:

Private Sub Command8_Click()
DoCmd.OpenForm "Cust5", , , , , , me.sessionID
End Sub


Private Sub Form_Load()
If Len(Me.OpenArgs & "") > 0 Then
Me.SessionID.DefaultValue = Me.OpenArgs
End If
End Sub
 
Back
Top