July 25, 2005 at 8:26 am
I have a subform in Access that shows credit card entries. The user is able to click the "Add Like" button and this will return a new record with the same information as the record selected before clicking the button. I have two issues: First, I would like for the new record to be selected after it is added to the subform. Second, I would like for the new record to appear at the end of the records on the subform (right now, it appears below the record where the user's cursor was). The first issue is more important to me to be resolved than the second.
July 26, 2005 at 10:05 am
Can you give me a brief explanation of what the code behind the "Add Like" button looks like. I don't need the exact code, but just kind of what it does. For example, does it do an insert into the underlying table, requery and then move the bookmark back to the original record?
July 26, 2005 at 10:21 am
Here is the code:
Dim strSP As String
DoCmd.Save
strSP = "Exec (stored procedure name) "
DoCmd.RunSQL strSP
(subformname).Requery
DoCmd.GoToRecord , , acLast
I tried to use the Bookmark function but could not get it to work. Any suggestions? acLast definitely does not work. The stored procedure adds the new record to the table and the subform is requeried to show the new record. Although the subform shows the new record, it puts it directly under whatever record your cursor was on previously (I would like for it to go to the bottom) and then it keeps the cursor/highlight on the same record your cursor was on previously (instead of putting it on the new record I just added). My biggest problem is the selection or the highlight of the new record after the requery....Thanks!
July 30, 2005 at 9:16 am
You could do a find on the form's recordset using the pk of the new record that was just added. That'll probably work. As to the record being added right below the other one, that is probably a sort order thing. The fields being sorted on are probably identical since they were copied from the previous record.
Hope that works for you.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply