finding a record in another form

A

Allen Browne

After a FindFirst, test the recorset's NoMatch property:

Dim frm As Form
DoCmd.OpenForm "Prsn"
Set frm = Forms("Prsn")

If Not IsNull(Me!ID) Then
With frm.RecordsetClone
.FindFirst "[ID] = " & me!ID
If .NoMatch Then
MsgBox "Not Found"
Else
frm.Bookmark = .Bookmark
End If
End With
End If

Set frm = Nothing


Note: If "ID" is a Text type field, you need extra quotes:
.FindFirst "[ID] = """ & me!ID & """"
 
F

Focus

i have a Continuous form with a list of all customers
while doble cliking a customers name i want to find him in another form
by using this code:

DoCmd.OpenForm "Prsn"
With Form_Prsn.RecordsetClone
.FindFirst "[ID] = " & me!ID
Form_Prsn.Bookmark = .Bookmark
End With

- end code-

the code dosn't match the right ID
if ID=10 the found result is 9
what can be wrong?

thanks
 
F

Focus

sorry it dosen't help
i get the same result
and MsgBox is not prompting

þþ"Allen Browne said:
After a FindFirst, test the recorset's NoMatch property:

Dim frm As Form
DoCmd.OpenForm "Prsn"
Set frm = Forms("Prsn")

If Not IsNull(Me!ID) Then
With frm.RecordsetClone
.FindFirst "[ID] = " & me!ID
If .NoMatch Then
MsgBox "Not Found"
Else
frm.Bookmark = .Bookmark
End If
End With
End If

Set frm = Nothing


Note: If "ID" is a Text type field, you need extra quotes:
.FindFirst "[ID] = """ & me!ID & """"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Focus said:
i have a Continuous form with a list of all customers
while doble cliking a customers name i want to find him in another form
by using this code:

DoCmd.OpenForm "Prsn"
With Form_Prsn.RecordsetClone
.FindFirst "[ID] = " & me!ID
Form_Prsn.Bookmark = .Bookmark
End With

- end code-

the code dosn't match the right ID
if ID=10 the found result is 9
what can be wrong?
 
A

Allen Browne

Are you aware that the record that has the value 10 in the ID field, may not
be the 10th record in the form?

For example, if you delete record 4, the record that has ID of 5 is still 5,
so the 9th record retains the value of 10 in its ID field.

If that is not what is going on, add some Debug.Print statements to the code
to see what is happening.

Add these 2lines immediately above the line Bookmark line, i.e.:
Debug.Print Me!ID
Debug.Print !ID
frm.Bookmark = .Bookmark

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Focus said:
sorry it dosen't help
i get the same result
and MsgBox is not prompting

~~"Allen Browne said:
After a FindFirst, test the recorset's NoMatch property:

Dim frm As Form
DoCmd.OpenForm "Prsn"
Set frm = Forms("Prsn")

If Not IsNull(Me!ID) Then
With frm.RecordsetClone
.FindFirst "[ID] = " & me!ID
If .NoMatch Then
MsgBox "Not Found"
Else
frm.Bookmark = .Bookmark
End If
End With
End If

Set frm = Nothing


Note: If "ID" is a Text type field, you need extra quotes:
.FindFirst "[ID] = """ & me!ID & """"

Focus said:
i have a Continuous form with a list of all customers
while doble cliking a customers name i want to find him in another form
by using this code:

DoCmd.OpenForm "Prsn"
With Form_Prsn.RecordsetClone
.FindFirst "[ID] = " & me!ID
Form_Prsn.Bookmark = .Bookmark
End With

- end code-

the code dosn't match the right ID
if ID=10 the found result is 9
what can be wrong?
 

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