Solved

How sequence by 1 for subsequent records

Posted on 2013-05-31
1
285 Views
Last Modified: 2013-05-31
This will be tricky I'm sure.

I have a form which is used to record a project.  A project can have more than one TransRecord which is a text field on the form.

So, for example, Project #1 may have a TransRecord (a text field), that is "TransRecord#1".  Then the same project, Project #1, could have a TransRecord that is "TransRecord #2" and so forth.

But also on this form is a 4 digit number field formatted to look like "0001", "0002", "0003" and so on.

Here's what I need to do... for the first record of a unique TransRecord I want the 4 digit number to automatically populate to read "0001".  Then for the next TransRecord I want the 4 digit number field to be "0002".  And so on.

I expect that the code will have to be in the afterupdate event of the TransRecord field but I can't begin to know how to code this.

Can someone help?
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39211788
You can use DMax to determine the "highest" value in a specific column in a table:

Dim MyMax As Double

MyMax = DMax("FieldContainingTheNumber", "YourTable", "TransferRecord=" & Me.YourTransferRecordField)

MyMax would then contain the highest value found, and you could then add 1 to it.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

739 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