Okay, I think you can do this from the Switchboard.
Does the combo box on the switchboard have a row source based on your Client
Table? If so, then here is how you can do it without a filter. The
FindFirst will not work in this case because the Client form is not yet open
and, as I stated previously, the switchboard has no row source.
So, in the After Update event of the combo use the OpenArgs argument of the
OpenForm method.
Docmd.OpenForm "frmClient", , , , , , Me.MyCombo
Now, in the Load event of the client form:
If Not IsNull(Me.OpenARgs) Then
With Me.RecordsetClone
.FindFirst "[ClientID] = " & Me.OpenArgs
If .NoMatch Then
MsgBox "Client " & Me.OpenArgs & " Not Found"
Else
Me.BookMark = .BookMark
End If
End With
End If
So what has happened is we have used the FindFirst to get the client, but
since we have to do it within the Client form, we have passed the client's
identifier to the form so it know which client to pull up.
--
Dave Hargis, Microsoft Access MVP
awach said:
The switchboard opens when the db is opened. It serves as a guide/pointer to
all the forms and reports. One of the main forms used most often is the
Client form so I wanted a quick way to get to the client form and a specific
client from the main/opening page (at this point, the Switchboard). In order
to do that I created a combo box listing all the client's name. The user has
the option to select a last name from that list and go directly to their
client page. This avoids the steps of having to open the clients form and
then do a separate search there.
Like I wrote before, I tried using a filtering method but it is creating an
error so I'm not sure what else I can do.
I supposed I could make another form in leiu of the Switchboard but I think
it would have the same issues because it's not bound to anything.
What do you think I should do?
:
Create a new form in design view.
What you are doing is not appropriate for the switchboard.
Maybe if you could describe in some detail what you are attempting to
accomplish, I could give some more detailed assistance.
--
Dave Hargis, Microsoft Access MVP
:
What do you mean when you sau "use your own form"? (sorry, I'm still learning)
I tried posting the code you supplied on the AfterUpdate of the Switchboard
search and it returns an error that Combo161 cannot be found. How do I fix
this?
Thanks!!!
:
The problem here is that the Switchboard doesn't have a Row Source. In other
words, there is no recordset for the switchboard.
I would suggest you use your own form and just open the form from the
switchboard. Then the code you posted should work. Just to disect it for
you:
This has some issues. Microsoft does some really bad programming.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[LastName] = '" & Me![Combo161] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
This would be my version:
With Me.RecordsetClone 'Use the form's
recordsetclone for the
'following
operations
.FindFirst "[LastName] = '" & Me.Combo161 & "'"
'Find the first
record where the LastName
'Field in the
recordset is equal to the
'value in the
control named Combo161
'on the Active
Form
If .NoMatch Then 'A match was not found
MsgBox "Record Not Found"
Else
Me.BookMark = .BookMark 'Make the record found in the
'recordsetclone
the current record on
'the form
End If
End With 'Ends the With
statement.
--
Dave Hargis, Microsoft Access MVP
:
I think the FindFirst method would work fine but I don't know how to do it.
I originally used it with the combo box wizard so I don't know how to write
the actual code. I have
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[LastName] = '" & Me![Combo161] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
for the combo box but because it is being opened from the Switchboard form
and not the [Clients] from, the Me. part doesn't work. I've tried replacing
that with the full location (Set rs=Forms!Switchboard!Search) name but it
still doesn't seem to work. How can I make this work? Thanks!
:
What is wrong with the FindFirst method? That is what I would use.
--
Dave Hargis, Microsoft Access MVP
:
I have a switchboard and a main client form. On the main client form I used
the combo box wizard to create a searching combo box-the user selects the
client name from the box and is taken to the first match (no filter, uses the
FindFind method).
I also have another combo box on my switch board as a shortcut. The user
can select the client's name from that list and go directly to the client
page with the matching last name. That combo is using a filtering method
which is causing an error that forces the entire access program to quit.
I'm think that if I can search without using a filter with the FindFirst (or
something similar) I could get rid of the error. ...But, I've been
troubleshooting for a while and come up with nothing. Any ideas? Thanks.
Forms:Switchboard, Clients
Controls: SwitchboardSearch, ClientSearch