edit function in a table

N

neuromoe

I have a form that lists employee accomplishments. I have to update these
all the time. The form has a table in it, and one of the columns in the
table is called "Edit." It used to be that if I needed to change an entry, I
could click on the "edit" column, and it would open another form that allows
me to see the full texts of each entry, pulling up the specific entry that I
wanted to edit. Now, when I click on the "edit" column, it just brings up
the first form in the database, and I have to go find the record that I want
to edit.

I'm not sure what happened. I recently moved this database to a secure
location, so that content could be permanently enabled, so maybe I broke a
link somehow. Can anyone help me get the "Edit" column to link to these
specific records again?

Thanks!
 
D

Duane Hookom

I expect there should be some code that you need to share. What code opens
the form? What happens if you click anywhere in the record prior to clicking
the Edit?
 
N

neuromoe

Hi Duane,

Yes, I think it has to do with VBA code, but I know nothing about Visual
Basic, so I can't answer your first question. If I click somewhere else in
the record before clicking edit, the same thing happens: it pulls up a blank
form and it's record 1 of 1. I can click the filter button, and then it'll
take me to the other 350 records so I can search through them, but it doesn't
filter correctly so that the right record opens. I have compared the VBA
code for the edit function with another database on which the function works,
but they seem to be the same. Again, I don't know Visual Basic, so I
probably don't know what I'm talking about. Any suggestions?

Thanks!
 
D

Duane Hookom

Try to go to the design view, find the code, copy it, and paste it into a
reply.

You could try creating a button in the detail section that would open the
form to display the current record. There is a wizard that should do all of
this for you.
 
N

neuromoe

Hi Duane,

I hope this is what you wanted. The only code i can find is this:

Option Compare Database

Private Sub Edit_Click()
DoCmd.OpenForm "Accomplishments", , , "Accomplishmentid = " &
Me.AccomplishmentID

End Sub


Is there somewhere else I should look?

Thanks!
 
D

Duane Hookom

That is the correct code and should open the form named "Accomplishments"
with a filter of AccomplishmentID equal to the AccomplishmentID of
form/subform where the code is running.
 
N

neuromoe

Hmmm... any thoughts on why the code is not working? Is there another
setting that may be off?

Thanks!
 
D

Duane Hookom

I would place a BreakPoint in the code to see what is happening. You could
then make sure the code is running and the values.

You could also change your code to:

Private Sub Edit_Click()
Dim strWhere as String
strWhere = ""Accomplishmentid = " & Me.AccomplishmentID
MsgBox "strWhere: " & strWhere
DoCmd.OpenForm "Accomplishments", , , strWhere

End Sub
 
N

neuromoe

Hi Duane,

I don't know how to place a BreakPoint... sorry! I did try running the code
that you suggested, but it gave me a syntax error when I tried to run it.

Any other suggestions?

Thanks a lot for the investment of your time!
 
J

John W. Vinson

I don't know how to place a BreakPoint...

Open the VBA editor and mouseclick in the vertical grey bar to the left of the
code window. Click next to the line at which you want the code to stop - it
must be an executable statement (i.e. not a Dim or a comment).
 
D

Duane Hookom

You also didn't catch my "intentional" error in this line:
strWhere = ""Accomplishmentid = " & Me.AccomplishmentID
which should be:
strWhere = "Accomplishmentid = " & Me.AccomplishmentID
This all assumes Accomplishmentid is numeric.
 

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