Re: Open a form at a specific record

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Your quotes do not match what we suggested for you to type in.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Hagan" <Hagan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:96A91E61-0A8D-45D6-AFF7-CAF2FBFF82BB@xxxxxxxxxxxxxxxx
As I write in: strWhere = "[actual club] = "blue
I am interupted, this line goes red, with the top line: Private Sub SDB
Click () becoming highlighted
and I get error message Compile error: Expected: end of statement.
This is the full code I am putting in, including the first two lines which
are already there before I start.

Private Sub SDB_Click()
On Error GoTo Err_SDB_Click
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False 'save first.
If Not IsNull(Me.[actual club]) Then
strWhere ="[actual club]= "blue and whites"
DoCmd.OpenForm "registered clubs", WhereCondition:=strWhere
End If

--
Hagan


"Hagan" wrote:

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" wrote:

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.

"Hagan" <Hagan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:12DC6589-3743-4B99-AD0E-72263AB32F03@xxxxxxxxxxxxxxxx
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.


.



Relevant Pages

  • Re: Can I still use check boxes?
    ... I declare de variable as String but the code does not work. ... Allen Browne - Microsoft MVP. ... Tips for Access users - http://allenbrowne.com/tips.html ... You'll need to build a filter string that looks like this: ...
    (microsoft.public.access.formscoding)
  • Re: Open a form at a specific record
    ... Allen Browne - Microsoft MVP. ... and I get error message Compile error: Expected: end of statement. ... Dim strWhere As String ...
    (microsoft.public.access.queries)
  • Re: Can I still use check boxes?
    ... You'll need to build a filter string that looks like this: ... Dim strTmp As String ... Allen Browne - Microsoft MVP. ... Tips for Access users - http://allenbrowne.com/tips.html ...
    (microsoft.public.access.formscoding)
  • Re: Can I still use check boxes?
    ... You'll need to build a filter string that looks like this: ... Dim strTmp As String ... Allen Browne - Microsoft MVP. ... Tips for Access users - http://allenbrowne.com/tips.html ...
    (microsoft.public.access.formscoding)
  • Re: Trapping Error 3101
    ... error message rather than the Access generated message. ... Allen Browne - Microsoft MVP. ... Tips for Access users - http://allenbrowne.com/tips.html ... I get an error "The Microsoft Jet database enfine ...
    (microsoft.public.access.formscoding)