Re-Post - Search For Record

G

Guest

I have a main form with two sub-forms.

On subform 2, I wish to add a control that will open a search box and locate
a record that matches what the user types in the search box.

I modified some code that I found, and it works fine. However, it opens the
sub form 2 a second time. I would like to simply display the record in the
currently open sub form. In other words, have it "act" like a regular
search. I am not using a regular search, as I wish users to be able to
easily search for a particular field content without any knowledge of Access.

Private Sub Command26_Click()
On Error GoTo Err_Command26_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_ppt_search"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command26_Click:
Exit Sub

Err_Command26_Click:
MsgBox Err.Description
Resume Exit_Command26_Click

End Sub
 
G

Guest

With Me.RecordsetClone
.MoveFirst
.FindFirst "[pkID] = " & Trim(CStr(lngRecordID))
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
 
G

Guest

Thanks for your reply. I am trying to understand this code - would you mind
explaining it?

From what I can see, I would need to make a selection in a combo box? What
I am trying to do is create an unbound control in which a user can type a ppt
number and click a search button. If the ppt number exists in the table
bound to the form, it will go it it; if not, it will display a message that
indicates the ppt number has not been added yet.

Thanks so much for your help.
--
Thanks!

Dee


Steve McLeod said:
With Me.RecordsetClone
.MoveFirst
.FindFirst "[pkID] = " & Trim(CStr(lngRecordID))
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With

--
Pictou


dee said:
I have a main form with two sub-forms.

On subform 2, I wish to add a control that will open a search box and locate
a record that matches what the user types in the search box.

I modified some code that I found, and it works fine. However, it opens the
sub form 2 a second time. I would like to simply display the record in the
currently open sub form. In other words, have it "act" like a regular
search. I am not using a regular search, as I wish users to be able to
easily search for a particular field content without any knowledge of Access.

Private Sub Command26_Click()
On Error GoTo Err_Command26_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_ppt_search"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command26_Click:
Exit Sub

Err_Command26_Click:
MsgBox Err.Description
Resume Exit_Command26_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top