open form with record from other form

M

miss031

I have a form with a command button to open another form, which I would like
to open with the same information displayed on the original form. Can you
filter a form by another form?

I also have a command to open a record filtered by this same form, but I
can't make it work either.
 
A

Allen Browne

Use the WhereCondition of OpenForm.

Example:
Dim strWhere As String
strWhere = "ID = " & Me.ID
DoCmd.OpenForm "Form2", WhereCondition:=strWhere

Notes:
1. Doesn't work if Form2 is already open.

2. Add extra delimiters if the field you are filtering on is not a Number.
For example if ID is a text field:
strWhere = "ID = """ & Me.ID & """"
More info on that:
http://allenbrowne.com/casu-17.html
 
M

miss031

That works, but I would now like to open the form as a new record, with the
ID number already filled in.

I also have, on the original form, a total of the contents of it's subform.
Can I bring this over the to newly opened form?
 
A

Allen Browne

Open the form in Add mode.
Then assign the value to the text box on the form:

DoCmd.OpenForm "Form2", DataMode:=acFormAdd
Forms!Form2!ID = Me.ID
 
M

miss031

Thank you very much.
That works perfectly!




Allen Browne said:
Open the form in Add mode.
Then assign the value to the text box on the form:

DoCmd.OpenForm "Form2", DataMode:=acFormAdd
Forms!Form2!ID = Me.ID
 
Top