Thank you, but I did warn you I am a beginner!
I assume I enter this by going to "Build Event" for the button. But I am
not sure where in the code you have written I put the name of the form to
be
opened, the field of the record to search and the actual name in that
particular field on to produce the particular record. Below I have used
"registered clubs" for the name of the form, "actual club" for the name
of
the field and "blue and whites" for the entry in the field for the record
that I am trying to produce, in the code that you gave me, but it doesn't
work so I am obviously not got the names in the right places.
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False 'save first.
If Not IsNull(Me.[actual club]) then
strWhere = "[actual club] = " & Me.[blue and whites]
DoCmd.OpenForm "[registered clubs]", WhereCondition:=strWhere
End If
I have tried various permutations without success. With the above I get
error message "Access can't find field '|' referred to in your
expression.
Any ideas?
--
Hagan
Allen Browne said:
Unless the target form is already open, you can open it filtered to
just the
one record by using the WhereCondition argument of OpenForm.
For example, if you have a Number field named ID:
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False 'save first.
If Not IsNull(Me.ID) then
strWhere = "ID = " & Me.ID
DoCmd.OpenForm "Form2", WhereCondition:=strWhere
End If
If you acutally want to open the form unfiltered, but move to the
desired
record, use FindFirst on the RecordsetClone of the form, and then match
bookmark.
Either way, the WhereCondition or FindFirst string is anything that you
could validly put in the WHERE clause of a query.
This is probably simple, but I am a bit of a beginner. I am trying
to
create
a button on a form - which I use as an opening men for the database -
that
will open another form at a specific record. The forms hold the
records
of
various organisations and their names are the primary key. I know
how to
build queries to get specific information, but not how to open an
entire
form
at a specific record.