same record in sub form

  • Thread starter FlyingDragon via AccessMonster.com
  • Start date
F

FlyingDragon via AccessMonster.com

hi all
i have a form called (CarsSearch) which has a text box called (CrimeNum) when
i click on it
it open more details about this field in another sub form called (Crimes) in
form called (Cars)
the code is
DoCmd.OpenForm "Cars", acNormal, , "[CrimeNum]=" & Me!CrimeNum

Me.CrimeNum.SetFocus

my problem is the sub form always open in the first record while i want to
open the same detail in the sub form
thanks for all
 
T

Tom van Stiphout

On Fri, 24 Apr 2009 19:10:20 GMT, "FlyingDragon via AccessMonster.com"

That is indeed the default behavior. To change it, you may need to
write some code to select the non-first record. HTe standard technique
is to set the bookmark of the subform equal to the bookmark of some
recordset. Something like this:
(in the Cars form_open (or perhaps form_load))
With me.mySubFormControl.Form.RecordsetClone
.FindFirst Me!CrimeNum
if .NoMatch then
debug.assert false 'This cannot happen in a well-designed db.
else
me.mySubformControl.Form.Bookmark = .Bookmark
end if
end with
(of course you replace myObjectNames with yours)

-Tom.
Microsoft Access MVP
 
F

FlyingDragon via AccessMonster.com

Tom said:
That is indeed the default behavior. To change it, you may need to
write some code to select the non-first record. HTe standard technique
is to set the bookmark of the subform equal to the bookmark of some
recordset. Something like this:
(in the Cars form_open (or perhaps form_load))
With me.mySubFormControl.Form.RecordsetClone
.FindFirst Me!CrimeNum
if .NoMatch then
debug.assert false 'This cannot happen in a well-designed db.
else
me.mySubformControl.Form.Bookmark = .Bookmark
end if
end with
(of course you replace myObjectNames with yours)

-Tom.
Microsoft Access MVP
hi all
i have a form called (CarsSearch) which has a text box called (CrimeNum) when
[quoted text clipped - 9 lines]
open the same detail in the sub form
thanks for all
many thanks for trieng help
i use the code like this


With Me.CrimeNum.Form.RecordsetClone
.FindFirst Me!CrimeNum
If .NoMatch Then
Debug.Assert False 'This cannot happen in a well-designed db.
Else
Me.CrimeNum.Form.Bookmark = .Bookmark
End If
End With

in my form (cars) in open and in load
but i get an error :
method or data member not found >> and it show me on word (form)
 

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