OpenArgs - Default value

A

Annette

I have a combo box that prompts for a participant name. If the
participant name is not in the list I have a procedure that will open
another form to allow the participant's name to be entered. When the
form opens, I place the "openarg" value in the participant name field
as the default value. There is other information that can be entered
about the participant like address, telephone number etc. If the
additional information is entered and the user closes the form, the
participant is added to the table and when they come back to the
calling form, the name is displayed. However, when there is no
additional information when it comes back to the calling form, it
can't find a record. I found out that the participant record is not
created by just have the default value assigned (I can see this
because the autonumber field still shows 'autonumber'). Therefore the
record isn't written to the participant table even though there is a
default value for the partipipant name.

How can I fake out the form and have that participant name written to
the table without any other information?
 
K

Ken Sheridan

If you want the new record to be saved every time then in the second form's
Load event procedure assign the value of the OpenArgs property to the
participant name control's Value property rather than its DefaultValue
property, e.g.

Me.[ParticipantName] = Me.OpenArgs

The Value property is the default property of a control so doesn't need to
be specifically referred to.

If you want the user to be able to elect whether to save the new record or
not with just the name in place then assign the value of the OpenArgs
property to the participant name control's DefaultValue property as at
present, but prompt the user when closing the form whether to save the record
or not by putting this in the form's Unload event procedure:

Const conMESSAGE = "Save new record?"

If Me.NewRecord And Not IsNull(Me.[ParticipantName]) And Not Me.Dirty Then
If MsgBox(conMESSAGE, vbYesNo, "Confirm") = vbYes Then
Me.[ParticipantName] = Me.OpenArgs
End If
End If

Ken Sheridan
Stafford, England
 

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