Form can be opened from multiple forms, needs to get value from different forms

  • Thread starter Thread starter Travis Law via AccessMonster.com
  • Start date Start date
T

Travis Law via AccessMonster.com

I am having an issue where I have a main form page. There is a record
number among other things. As well as buttons to open 4 other forms. When
you press the button, it opens desired form with the record that matches
the same record number you entered. Now you have the option to open up the
other forms from the new form. How do I get the other forms to open up
with the matching record number but be able to accept the value from any
form? For now it only gets the value from the main form page, I need it to
accept a value from any form.

Here is the code on the new page.

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord acDataForm, "New", acGoTo, [Forms]![Front Page]![Form ID
number].Value
End Sub

Any help would be greatly appreciated.
 
Travis said:
I am having an issue where I have a main form page. There is a record
number among other things. As well as buttons to open 4 other forms. When
you press the button, it opens desired form with the record that matches
the same record number you entered. Now you have the option to open up the
other forms from the new form. How do I get the other forms to open up
with the matching record number but be able to accept the value from any
form? For now it only gets the value from the main form page, I need it to
accept a value from any form.

Here is the code on the new page.

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord acDataForm, "New", acGoTo, [Forms]![Front Page]![Form ID
number].Value
End Sub


There are several ways to approach this. If you want the
new form to display only the matching record(s?), then use
the OpenForm method's WhereCondition argument to filter the
new form's data to only the matching records:
DoCmd.OpenForm "theform", , , "IDfield = " & Me.IDfield

If you do not want to filter the data, but just position the
current record to a matching record, then you can use the
OpenForm method's OpenArgs argument to pass the ID number to
the newly opened form:
DoCmd.OpenForm "theform", OpenArgs:=Me.IDfield
then the form can use that value to go to the desired
record:
DoCmd.GoToRecord acDataForm, "New", acGoTo, Me.OpenArgs
 
Back
Top