Openargs and gotorecord

G

Guest

I have two forms, AllEmployees and OneEmployee. If on the AllEmployees form
a user is at a record with the textbox, say "Joe", the user hits the command
button and OneEmployee opens showing Joe's record. AllEmployees closes (so
only OneEmployee is open). If the user goes back to AllEmployees, I'd like
the user to be at Joe's record but still able to scroll through all the other
records (so I can't filter) but I am stuck on how to do this.

At first I thought of using DoCmd.GoToRecord but I need the offset which I
don't know how to calculate. Also, I thought of using the record number when
I saw the navigation buttons showing me the record number but I don't know if
there's a property for this. Then I began looking into using OpenArgs but if
my OpenArgs is "Joe" I don't know a function like GoToRecord that uses some
sort of link other than offset.

Thanks in advance.
 
D

Dirk Goldgar

juicegully said:
I have two forms, AllEmployees and OneEmployee. If on the
AllEmployees form a user is at a record with the textbox, say "Joe",
the user hits the command button and OneEmployee opens showing Joe's
record. AllEmployees closes (so only OneEmployee is open). If the
user goes back to AllEmployees, I'd like the user to be at Joe's
record but still able to scroll through all the other records (so I
can't filter) but I am stuck on how to do this.

At first I thought of using DoCmd.GoToRecord but I need the offset
which I don't know how to calculate. Also, I thought of using the
record number when I saw the navigation buttons showing me the record
number but I don't know if there's a property for this. Then I began
looking into using OpenArgs but if my OpenArgs is "Joe" I don't know
a function like GoToRecord that uses some sort of link other than
offset.

If you want to dedicate OpenArgs to this purpose, so that if any
OpenArgs is passed to AllEmployees, it finds the record that matches it
(in a specific field), then you could have code like this in the form's
Load event:

'----- start of example code -----
Private Sub Form_Load()

If Not IsNull(Me.OpenArgs) Then

With Me.RecordsetClone
.FindFirst "EmployeeName = " & _
Chr(34) & Me.OpenArgs & Chr(34)
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With

End If

End Sub
'----- end of example code -----
 
G

Guest

Hi Dirk,

Is there a way of doing this without using recordsets? Or is there a way of
finding the offset? I was thinking that I could also just make the
AllEmployees form invisible for awhile but I wanted to find another option.

Thanks
 
D

Dirk Goldgar

juicegully said:
Hi Dirk,

Is there a way of doing this without using recordsets? Or is there a
way of finding the offset? I was thinking that I could also just
make the AllEmployees form invisible for awhile but I wanted to find
another option.

The offset is meaningless, as it isn't guaranteed to be the same when
the form is reopened. What's wrong with using the recordsetclone?
That's what's going on behind the scenes if you use any of the built-in
Find methods.

Yes, you could make the AllEmployees form invisible and then just show
it again, if you want.
 
G

Guest

Hi

I think I'll just stick to using the invisible and visible properties. When
I first started coding with Access 3 months ago I was told not to work with
recordsets b/c I wouldn't need to (the guy I talked to is very familiar with
Access) so i've never looked too much into them.

Thanks for your help
 
D

Dirk Goldgar

juicegully said:
Hi

I think I'll just stick to using the invisible and visible
properties.

That's probably the right choice in this case, if you can do that.
When I first started coding with Access 3 months ago I
was told not to work with recordsets b/c I wouldn't need to (the guy
I talked to is very familiar with Access) so i've never looked too
much into them.

Lots of Access novices try to use recordsets to do things that Access
will do for them automatically if they let it, or to do things that can
be better done with queries alone. Maybe that's what you were being
cautioned against. Rejecting the use of recordsets altogether, even
when it's the best way to accomplish something, is "throwing the baby
out with the bathwater".
 

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

Similar Threads

GotoRecord with a variable 1
OpenArgs problem I think 2
GoToRecord Sintax 6
erratic OpenArgs behavior 2
Openargs Not Working 2
GoToRecord 1
Paasing an array in OpenArgs 3
GoToRecord acCurrent?? 5

Top