GoTo Specific Record

G

Guest

I am not efficient in code. I am using Access for the first time and the last
time I did any computer programming I was in high school (a long time ago). I
am trying to get one form to goto a specific record on another form when I
double click. I found some code on the internet to use but I don't quite
understand it. Could someone please help. The code I found is:

Private Sub Text1_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[staffID] = " & Str(Nz(Me![Text1], 0))
If rs.EOF = False Then
Me.Bookmark = rs.Bookmark
Else
DoCmd.GoToRecord acActiveDataObject, , acNewRec

I don't understand exactly what the "Text1" is in reference to. Can someone
please explain?
 
A

Alex Dybenko

Text1 -is a textbox on a form
this is event which is fired, when you update this textbox
then is finds a record in form's recordset and set bookmark to it
 
G

Guest

Thank you. Now try this. I have changed that to be the same as my label and
it isn't working. It says that it doesn't exist in my database. Please help.
I am just trying to write a simple goto specific record statement.

Alex Dybenko said:
Text1 -is a textbox on a form
this is event which is fired, when you update this textbox
then is finds a record in form's recordset and set bookmark to it

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


IGreen said:
I am not efficient in code. I am using Access for the first time and the
last
time I did any computer programming I was in high school (a long time
ago). I
am trying to get one form to goto a specific record on another form when I
double click. I found some code on the internet to use but I don't quite
understand it. Could someone please help. The code I found is:

Private Sub Text1_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[staffID] = " & Str(Nz(Me![Text1], 0))
If rs.EOF = False Then
Me.Bookmark = rs.Bookmark
Else
DoCmd.GoToRecord acActiveDataObject, , acNewRec

I don't understand exactly what the "Text1" is in reference to. Can
someone
please explain?
 
A

Alex Dybenko

if you have a form, bound to a table or query - try to add a combobox to it
header - wizard will help you to build code for your form

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


IGreen said:
Thank you. Now try this. I have changed that to be the same as my label
and
it isn't working. It says that it doesn't exist in my database. Please
help.
I am just trying to write a simple goto specific record statement.

Alex Dybenko said:
Text1 -is a textbox on a form
this is event which is fired, when you update this textbox
then is finds a record in form's recordset and set bookmark to it

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


IGreen said:
I am not efficient in code. I am using Access for the first time and the
last
time I did any computer programming I was in high school (a long time
ago). I
am trying to get one form to goto a specific record on another form
when I
double click. I found some code on the internet to use but I don't
quite
understand it. Could someone please help. The code I found is:

Private Sub Text1_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[staffID] = " & Str(Nz(Me![Text1], 0))
If rs.EOF = False Then
Me.Bookmark = rs.Bookmark
Else
DoCmd.GoToRecord acActiveDataObject, , acNewRec

I don't understand exactly what the "Text1" is in reference to. Can
someone
please explain?
 
D

David C. Holley

Or if you're opening the form when the double click happens, you can use
the WHERE statement as in...

DoCmd.OpenForm [formName],[....],"[lngTransportId] = " & [name of text
field]
 
G

Guest

Now I think I'm more confused. Let's start from scratch. I have created a
media databse. I started by creating a table called Artist Information. Form
that table I created two different forms. One has all the fields of the table
in it and the other only has the Artist Name field. The one that only has the
Artist Name field in it is for searching purposes. I want to be able to
scroll down through the list and find the artist I want, then double click on
the artist name and be directed to the specifc artist in the other form.

Now remember, I have NO idea what I'm doing. The things I have gotten to
work so far have been by sheer stuborness. I can't seem to walk away until it
works.

I don't really understand what these statements are doing so I think I'm
either not making the correct changes to make them in my database or either I
am not explaining myself correctly.

In the statement: DoCmd.OpenForm [formName],[....],"[lngTransportId] = " &
[name of text field]
I don't understand what the "[....],"[lngTransportId]" is.
Is it standard or does it need to be changed to something in my database.

With my first attempt I tried change the " Text1" to "ArtistName" and it
didn't work. Could that be because my fields are labeled the same as my
titles?


David C. Holley said:
Or if you're opening the form when the double click happens, you can use
the WHERE statement as in...

DoCmd.OpenForm [formName],[....],"[lngTransportId] = " & [name of text
field]

Alex said:
Text1 -is a textbox on a form
this is event which is fired, when you update this textbox
then is finds a record in form's recordset and set bookmark to it
 

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