Cannot use copy record button on form with lookup box

S

Stacey Crowhurst

Hi. I posted the following message on 12/01/09 but did not get any replies.
I am unsure if it is an unanswerable question or not...

Hi. I have two forms that I would like to add a copy record button to. But
I get error messages [Run-time error 3414] when I try. It points to this
line of code when I click debug: If Not rs.EOF Then Me.Bookmark = rs.Bookmark

After troubleshooting for a bit, I realized that both forms have lookup
boxes in the form header section. If I delete the lookup box from the form I
can add a duplicate record button without a problem. Is there anyway to have
both the lookup box and the duplicate record button on the form
simulatneously?

Here is the code for one of the lookup boxes (from the wizard)

Private Sub lkpCostCode_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[cocCostCodeID] = '" & Me![lkpCostCode] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Let me know if you need more information or have questions.

Thank you in advance !!! :)

Stacey
 
M

Marshall Barton

Stacey said:
Hi. I posted the following message on 12/01/09 but did not get any replies.
I am unsure if it is an unanswerable question or not...

Hi. I have two forms that I would like to add a copy record button to. But
I get error messages [Run-time error 3414] when I try. It points to this
line of code when I click debug: If Not rs.EOF Then Me.Bookmark = rs.Bookmark

After troubleshooting for a bit, I realized that both forms have lookup
boxes in the form header section. If I delete the lookup box from the form I
can add a duplicate record button without a problem. Is there anyway to have
both the lookup box and the duplicate record button on the form
simulatneously?

Here is the code for one of the lookup boxes (from the wizard)

Private Sub lkpCostCode_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[cocCostCodeID] = '" & Me![lkpCostCode] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub


That's the junk the stupid wizard created, right? The code
should be more like:

Private Sub lkpCostCode_AfterUpdate()
With Me.RecordsetClone
.FindFirst "cocCostCodeID='" & Me!lkpCostCode & "'"
If Not .NoMatch Then Me.Bookmark = .Bookmark
End With
End Sub
 
S

Stacey Crowhurst

THANK YOU THANK YOU THANK YOU!!! I have been wanting this functionality for
six months now! Yay! My opinion of the wizard has declined dramatically :)

Thanks!

Marshall Barton said:
Stacey said:
Hi. I posted the following message on 12/01/09 but did not get any replies.
I am unsure if it is an unanswerable question or not...

Hi. I have two forms that I would like to add a copy record button to. But
I get error messages [Run-time error 3414] when I try. It points to this
line of code when I click debug: If Not rs.EOF Then Me.Bookmark = rs.Bookmark

After troubleshooting for a bit, I realized that both forms have lookup
boxes in the form header section. If I delete the lookup box from the form I
can add a duplicate record button without a problem. Is there anyway to have
both the lookup box and the duplicate record button on the form
simulatneously?

Here is the code for one of the lookup boxes (from the wizard)

Private Sub lkpCostCode_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[cocCostCodeID] = '" & Me![lkpCostCode] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub


That's the junk the stupid wizard created, right? The code
should be more like:

Private Sub lkpCostCode_AfterUpdate()
With Me.RecordsetClone
.FindFirst "cocCostCodeID='" & Me!lkpCostCode & "'"
If Not .NoMatch Then Me.Bookmark = .Bookmark
End With
End Sub
 

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

Copy Record Button Function 1
Dynamic Naming of Form Button 3
Clearing combo boxes and a text box 2
Error 2237 8
Error 2147352567 2
Search combo box 2
Cobo Box lookup record on a form 1
Textbox Filter 4

Top