Solved

Duplicate record Wizard not producing correct results.

Posted on 2014-03-01
6
223 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
ID: 39898172
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
ID: 39898400
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
ID: 39898578
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 84
ID: 39898625
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
ID: 39898655
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
ID: 39899066
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

679 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