Set default text field from previous form

  • Thread starter Thread starter zoltar
  • Start date Start date
Z

zoltar

Hi,
I'm new to Access and need some help to set up a form.

At the moment I have a form where you make a selection of a client from
a combo box.
Then you click on a 'view projects' button and a new form opens
displaying the project records for that client. This all works fine.

However, I'd like to set a text field on the projects form to display
the client which was selected on the first form. This text field should
display the client by default even when a 'new record' is added so that
the user doesn't have to choose the client from a drop-down.

So how can I retrieve the value from the first form and set a locked
text box that keeps displaying the value even for an otherwise blank
new record.?

thanks,
Dave
 
There are a couple of ways to do this. One would be to make your View
Projects form a sub form. This will make it a lot easier. If you can't do
that, you can use the OpenArgs argument of the OpenForm method to pass the
client id to the second form, and set the form's filter using that value.

In First Form:

DoCmd.OpenForm "SecondForm", , , , , Me.ClientID

In the Load event of the second form

strClient = Me.OpenArgs
if len(strClient) > 0 Then
Me.Filter = "[ClientID] = '" & strClient & "'"
Me.FilterOn = Trhe
End If
 
Back
Top