Go To Record VB HELP =(

G

Guest

I've been searching all day & for some reason I can't find the (probably
simple) answer to this question.

How do I select a specific record in a subform?


DoCmd.GoToRecord acSomething, SomethingElse, Subform.ID = intID, acGoTo (??)

I just want to be able jump to the record where ID = intID (where ID is
always an existing value for a record).




I saw this somewhere else,

Me.SSbranch.Form.RecordsetClone.FindFirst "ID = " & usocIDcheck

If Not Me.SSbranch.Form.RecordsetClone.NoMatch Then
Me.SSbranch.formBookmark = Me.Alertsub.Form.RecordsetClone.Bookmark
End If


I couldn't get it to work either though =(

thanks SO MUCH for any help~
 
B

Baz

The sample code you posted using bookmarks is exactly the way to do it. If
it doesn't work for you, you'd best post the code that you tried, and
explain in what sense it doesn't work.
 
G

Guest

Private Sub usocupdatecommand_Click()

If usocIDcheck <> Me!SSbranch.Form!ID Then

Me.SSbranch.Form.RecordsetClone.FindFirst "ID = " & usocIDcheck

If Not Me.SSbranch.Form.RecordsetClone.NoMatch Then
Me.SSbranch.Form.Bookmark = Me.Alertsub.Form.RecordsetClone.Bookmark
End If

End If

Me!SSbranch.Form!ILEC = Me!usocileccombo
Me!SSbranch.Form!ST = Me!usocstcombo
...
Me!SSbranch.Form!Archived = Me!usocarchivedcheck

Me!SSbranch.Requery


End Sub


usocIDcheck is set by a dif action (when a record in the subform is clicked
on)

The problem is it wont select the new record, so the data in the text boxes
(on the main form) are put into the wrong record.

This whole code is necessary because of the other ways to select records
(events that I can't detect, ex: clicking on a cell instead of the recordbar
on the left).

Thanks again so much for any help~
 
G

Guest

OH crap lol.

Found the problem while rereading this--
Just put the wrong subform name in by mistake.

Thanks Baz, & sorry.
wish I knew how to delete a thread.... =)
 
D

Dirk Goldgar

In
Kaseano said:
I saw this somewhere else,

Me.SSbranch.Form.RecordsetClone.FindFirst "ID = " & usocIDcheck

If Not Me.SSbranch.Form.RecordsetClone.NoMatch Then
Me.SSbranch.formBookmark = Me.Alertsub.Form.RecordsetClone.Bookmark
End If

I couldn't get it to work either though =(

There's a small bug and a large bug in the code above, as posted. Small
bug: a missing dot (.) between "form" and "Bookmark". Large bug: the
reference to "Alertsub" seems to be in error; shouldn't that be
"SSbranch"?

Try this, or something like it:

With Me.SSbranch.Form.RecordsetClone
.FindFirst "ID = " & usocIDcheck
If Not .NoMatch Then
Me.SSbranch.Form.Bookmark = .Bookmark
End If
End With

If the ID field is text, not numeric, use

.FindFirst "ID = '" & usocIDcheck & "'"

instead of the corresponding line above.
 
B

Baz

No worries. We all overlook this sort of thing all the time, it's only when
trying to explain it to someone else that the penny drops!!!

Note Dirk's post, he's looked at it closer than me and spotted some other
possible problems.
 
G

Guest

Dirk Goldgar said:
In

There's a small bug and a large bug in the code above, as posted. Small
bug: a missing dot (.) between "form" and "Bookmark". Large bug: the
reference to "Alertsub" seems to be in error; shouldn't that be
"SSbranch"?

Try this, or something like it:

With Me.SSbranch.Form.RecordsetClone
.FindFirst "ID = " & usocIDcheck
If Not .NoMatch Then
Me.SSbranch.Form.Bookmark = .Bookmark
End If
End With

If the ID field is text, not numeric, use

.FindFirst "ID = '" & usocIDcheck & "'"

instead of the corresponding line above.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Yea I caught the small & large Finally after posting.
I never really bothered with the with statement but it looks rediculously
useful in keeping the code organized-- so thanks a lot dirk~
 

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