Solved

Duplicate record Wizard not producing correct results.

Posted on 2014-03-01
6
219 Views
Last Modified: 2014-04-05
I have attached my sample database.  If you click on a record on the main screen it will bring you to the Case Details screen.  When you click on "create Additional Review" button it creates a new record however the fileno (automatically created) does not change, which is causing a problem. The fileno is the text box to the right of the Act 6 check box.  I want that number to change when I execute the macro "create additional Review".

The database does not contain any confidential information.
DMC-Backup-Backup.accdb
0
Comment
Question by:seamus9909
  • 3
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
Sheils earned 500 total points
Comment Utility
I could not download your db so I will take a shot in the dark.

If I understand you correctly, you want to update the file number when you do a revision. EG file 123 becomes file 123.1.

If so I suggest that you create an additional field call fldversionnumber. The you can add the following code in the after update event of the form

Me.fldversionnumber=Me.fldversionnumber + 1
0
 
LVL 84
Comment Utility
Your database won't open - it's looking for "C:\DMCACS\DMC_Backpu_Backup_be.accdb", which of course does not exist on anyone else's machine.

Make all your tables local, then upload it again.

Also, be sure to Compact your database before uploading.

I can't see the Nav Pane either, and I cannot resize it. That may be because of the path error, but be sure that the database is easily usable, and accessible, before uploading it again.
0
 

Author Comment

by:seamus9909
Comment Utility
I attached both the FE and BE versions of the database so you can link them locally.  

Thanks for all your help
DMC-Backup-Backup.accdb
DMC-Backup-Backup-be.accdb
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 84
Comment Utility
You use this code to write a FileNo in the Form's BeforeUpdate event:

If Me.NewRecord Then
    Me.FileNo = Year(Date) & "1" & Format(Me.InvoiceID, "00000")
End If

You could use the same code in your "Create Additional Review" button to write a new fileno. Of course, the code above does not take into account whether the calculated value would already exist, so you may need to change that if you want unique FileNo values.

I'd also suggest you get away from macros. VBA is the language to use unless you're creating apps for your use only (and you can handle the errors that inevitably occur).
0
 

Author Comment

by:seamus9909
Comment Utility
Scott

I already have the Beforeupdate event set to that if statement.  SO when I execute the Wizard it copies the FileNo and then doesn't think its a new record so the beforeUpdate event does not run.  So I have a duplicate number created

How would I Put that command into the macro itself?
0
 
LVL 84
Comment Utility
then doesn't think its a new record so the beforeUpdate event does not run
The Before Update event runs every time you add or update a record, so I think you mean that the "If Me.NewRecord" test does not pass.

If your goal is to create a new record, then get rid of the macro, and do it the right way:

1) Open a recordset that contains the values you want to use for the copy - for example:

Dim rst As DAO.Recordset
Set rst = Currentdb.OpenRecordset("SELECT * FROM YourTable WHERE IDField=" & Me.IDField)

2) Now create a new record:

DoCmd.RunCommand acCmdRecordsGoToNew

3) Now insert values:

Me.txControl1 = rst("Col1")
Me.txControl2 = rst("Col2")

When you do this, you could then run your code that creates the FileNo.

You should never use copy and paste to create records in a database.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now