Automatically populating a field

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
 
S

Sandra Daigle

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
 

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

Top