Allen Browne's code to duplicate records

D

Dudley

I am trying to use Allen Browne's code to duplicate records as a command
button on a form in Access 2000 as

Private Sub Command136_Click()
Dim strSql As String
Dim lngID As Long

If Me.Dirty Then
Me.Dirty = False
End If

If Me.NewRecord Then
MsgBox "Select record to duplicate"
Else

With Me.RecordsetClone
.AddNew
!PresenterID = Me.PresenterID
!SameDay = Me.SameDay
!CompanyName = Me.CompanyName
etc
.Update
Me.Bookmark = .LastModified
End With
End If

End Sub

I get a record with blank fields (except ones with default data), and I
cannot see what I am doing wrong.

Thanks for any help.
Dudley
 
R

ruralguy via AccessMonster.com

Have you single stepped the code to see what is actually happening?
 
D

Dudley

How do I single step? I have tried F8, and Edit and step into, but nothing
happens (apart from a beep). Is there an option I need to set?

Thanks
Dudley
 
R

ruralguy via AccessMonster.com

Click outside the left margin to set a breakpoint and then run the code and
it will halt at your breakpoint to let you single step.
How do I single step? I have tried F8, and Edit and step into, but nothing
happens (apart from a beep). Is there an option I need to set?

Thanks
Dudley
Have you single stepped the code to see what is actually happening?
[quoted text clipped - 31 lines]
 
D

Dudley

My mistake. The code does not run. Advice welcome.
Dudley

Dudley said:
I tried this and I was able to put in the break point but when I clicked run
it looked for a macro and would not run the code I wanted it to. However,
when I tried running again from the command button the code ran OK. I find it
strange how often code does not work at first and then suddenly does for no
apparent reason. I will now try the next stage of Allen Browne's code,
duplicating sub-forms. Thanks for your help.

Dudley

ruralguy via AccessMonster.com said:
Click outside the left margin to set a breakpoint and then run the code and
it will halt at your breakpoint to let you single step.
How do I single step? I have tried F8, and Edit and step into, but nothing
happens (apart from a beep). Is there an option I need to set?

Thanks
Dudley

Have you single stepped the code to see what is actually happening?

[quoted text clipped - 31 lines]
Thanks for any help.
Dudley

--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.



.
 
D

Dudley

I tried this and I was able to put in the break point but when I clicked run
it looked for a macro and would not run the code I wanted it to. However,
when I tried running again from the command button the code ran OK. I find it
strange how often code does not work at first and then suddenly does for no
apparent reason. I will now try the next stage of Allen Browne's code,
duplicating sub-forms. Thanks for your help.

Dudley

ruralguy via AccessMonster.com said:
Click outside the left margin to set a breakpoint and then run the code and
it will halt at your breakpoint to let you single step.
How do I single step? I have tried F8, and Edit and step into, but nothing
happens (apart from a beep). Is there an option I need to set?

Thanks
Dudley
Have you single stepped the code to see what is actually happening?
[quoted text clipped - 31 lines]
Thanks for any help.
Dudley

--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.



.
 
R

ruralguy via AccessMonster.com

In Access you can't just "run" code usually. You need to execute it as it
would from a form.
I tried this and I was able to put in the break point but when I clicked run
it looked for a macro and would not run the code I wanted it to. However,
when I tried running again from the command button the code ran OK. I find it
strange how often code does not work at first and then suddenly does for no
apparent reason. I will now try the next stage of Allen Browne's code,
duplicating sub-forms. Thanks for your help.

Dudley
Click outside the left margin to set a breakpoint and then run the code and
it will halt at your breakpoint to let you single step.
[quoted text clipped - 10 lines]
 
D

Dudley

Thanks for your help. I finally found that it was a problem with my copy of
Access 2000, and solved it by upgrading to 2007.
Dudley

ruralguy via AccessMonster.com said:
In Access you can't just "run" code usually. You need to execute it as it
would from a form.
I tried this and I was able to put in the break point but when I clicked run
it looked for a macro and would not run the code I wanted it to. However,
when I tried running again from the command button the code ran OK. I find it
strange how often code does not work at first and then suddenly does for no
apparent reason. I will now try the next stage of Allen Browne's code,
duplicating sub-forms. Thanks for your help.

Dudley
Click outside the left margin to set a breakpoint and then run the code and
it will halt at your breakpoint to let you single step.
[quoted text clipped - 10 lines]
Thanks for any help.
Dudley

--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.




.
 

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