Your code does not have any action to change the CurrentRecord of the
newly-opened Form (frmTherapistInformation) and therefore the Form
displaysthe "first" Record.
My guess is that you got confused with the word "Me" which refers to the
Object whose context the code is executed in, in the case the frmSearch and
NOT the frmTherapistInformation. Thus the last 2 statements:
varBookmark = rstTherapist.Bookmark
Me.Bookmark = varBookmark
do nothing regarding the current Record of the Form frmTherapistInformation.
Another thing you may not be aware of is that 2 different Recordsets, even
if they refer to the same set of Records, will have different BookMarks so
had the "Me" above referred to frmTherapistInformation, you still most
likely won't get to the right Record (you may even get an error).
Try:
****Untested code****
Private Sub cmdSearch_Click()
' This seeks a specific APAC Therapist on the form and takes the user to
the correct record.
Dim rstTherapist As DAO.Recordset
Dim frmTI As Access.Form
DoCmd.OpenForm "frmTherapistInformation", datamode:=acFormEdit
DoEvents
Set frmTI = Forms("frmTherapistInformation")
Set rstTherapist = frmTI.RecordsetClone
rstTherapist.FindFirst "[TherapistID] = " & Me.cboName
' (by convention, "cbo" for ComboBox)
If (rstTherapist.NoMatch = False) Then
frmTI.Bookmark = rstTherapist.Bookmark
End If
' Cleaning up
DoCmd.Close acForm, Me.Name, acSaveNo
rstTherapist.Close
Set rstTherapist = Nothing
Set frmTI = Nothing
End Sub
********
HTH
Van T. Dinh
MVP (Access)
Catherine said:
Dirk,
Thank you for your help. Now that I have made the control unbound, the
combo box will allow me to change the value in it. (I don't understand why
another form will work with the control bound and this one will not, but
making it unbound fixed the problem.)
Now, I'm still having some trouble with my actual search feature (sigh).
Maybe you can find what's not working in the code below to explain why the
record I find is not the record displayed, but instead the first record is
displayed.
Private Sub cmdSearch_Click()
'This seeks a specific APAC Therapist on the form and takes the user to the correct record.
Dim rstTherapist As DAO.Recordset
Dim strTherapistID As String
Dim intTherapistID As Integer
Dim varBookmark As Variant
Set rstTherapist = Me.RecordsetClone
intTherapistID = Me.txtName.Column(1)
rstTherapist.FindFirst ("TherapistID=" & intTherapistID)
If Not rstTherapist.nomatch Then
Me.Bookmark = rstTherapist.Bookmark
End If
Me.txtName = Null
DoCmd.OpenForm "frmTherapistInformation", datamode:=acFormEdit
varBookmark = rstTherapist.Bookmark
Me.Bookmark = varBookmark
End Sub
I will look for responses in the next couple of days. THANKS!
--Catherine
Dirk Goldgar said:
I'm using the form as a search form. The only other control is a
command button. I'm not getting any errors, although initially I got
an error that stated the control could not be edited because it was
bound to an autonumber field. That error no longer appears in the
status bar and no error box appears.
Query in SQL: SELECT [FirstName] & " " & [LastName] AS Name,
tblTherapistContactInfo.TherapistID
FROM tblTherapistContactInfo
ORDER BY tblTherapistContactInfo.LastName,
tblTherapistContactInfo.FirstName;
Control Source = Name
Row Source Type = Table/Query
Row Source = qryFindAPACTherapist
Bound Column = 2
Column Count = 2
Column Width = 2";0"
I'm still stumped. I have experienced corruption in some of my
databases on forms and I needed to start them over. I've tried
starting this form again, even in a different database, and I'm still
struggling. I'm a little baffled. I appreciate your quick responses,
Dick, and hope you can find the problem I'm having.
You say the form is being used as a search form. Shouldn't it be
unbound, then? Yet your combo box has a ControlSource. That doesn't
make sense if this is a search control. Try clearing the combo box's
ControlSource property.
I'm afraid my "quick responses" have to end now, as I have to go offline
for the evening. I'll check back later to see if this has helped at
all. Good luck.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)