Open Form to a matching record (1 Viewer)

rothjm

Registered User.
Local time
Today, 07:59
Joined
Jun 3, 2003
Messages
46
I have two forms in my database. One for equipment and one for the network information.

I want to open the frmIP from the frmEquip and be on the coresponding record by matching the NIC Mac address field.
Currently, I can do it but it is done by a filter...I don't want a filter...I just want to open to that record but be able to access the rest of the table without turning off the filter.

Here is my code:
Code:
Private Sub cmdOpenIPForm_Click()
On Error GoTo Err_cmdOpenIPForm_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
       
    stDocName = "frmIP"
    stLinkCriteria = "[NIC_MAC]=" & "'" & Me![NIC_MAC] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    
Exit_cmdOpenIPForm_Click:
    Exit Sub

How can I open the form and goto the record with the matching NIC_MAC (without a filter)?
Thanks for the assistance, Jeff.
 

antomack

Registered User.
Local time
Today, 13:59
Joined
Jan 31, 2002
Messages
215
Check out the bookmark property in the access help, should do what you want. See extract below.

To test the following example with the Northwind sample database, you need to add a command button named cmdFindContactName to the Suppliers form, and then add the following code to the button's Click event. When the button is clicked, the user is asked to enter a portion of the contact name to find. If the name is found, the form's Bookmark property is set to the Recordset object's DAO Bookmark property, which moves the form's current record to the found name.
Code:
Private Sub cmdFindContactName_Click()
	Dim rst As Recordset, strCriteria As String
	strCriteria = "[ContactName] Like '*" & InputBox("Enter the " _
		& "first few letters of the name to find") & "*'"

	Set rst = Me.RecordsetClone
	rst.FindFirst strCriteria
	If rst.NoMatch Then
		MsgBox "No entry found"
	Else
		Me.Bookmark = rst.Bookmark
	End If
End Sub
 

rothjm

Registered User.
Local time
Today, 07:59
Joined
Jun 3, 2003
Messages
46
Thanks for your suggestion!
 

Users who are viewing this thread

Top Bottom