Solved

DMAX with Letters - Alphanumeric

Posted on 2006-07-13
5
441 Views
Last Modified: 2011-04-14
I have a form where I have a control that calculates a DMax for a field in a table. This works fine and the current value is AT1372

I now need to create the next ID number which will be fed into the next episode that is entered into the database (the answer should be AT1373). Unfortunately I cannot get it to add another digit.

The textbox that I have created which gives the DMax have the following equation:

=DMax("[Episode]","UploadCCT")
Textbox is called EPISODEmax

As I mentioned above this is working

I have tried NZ and also +1 outside brackets etc but it won't work. Is there a way of doing this or will the letters (AT) be preventing the calculation?
0
Comment
Question by:martywal
5 Comments
 
LVL 4

Assisted Solution

by:Carl2002
Carl2002 earned 75 total points
ID: 17100564
marytwal

you are correct in your thinking that the AT is preventing the addition as its a textfield. you need to think about splitting the text and numbers adding 1 to the number and then concatenanting again
0
 
LVL 44

Accepted Solution

by:
GRayL earned 100 total points
ID: 17100599
Assuming there is always a two-letter prefix try this:

=left(mystr,2) & strreverse(val(strreverse(mystr)))+1
0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 75 total points
ID: 17100608
U could perhaps use this function to extract the numeric, then add one
e.g.

Public Function ExtractNumeric(ByVal sWord As String) As String

    Dim i As Integer
    Dim sNewNumber As String
   
    sNewNumber = ""
    For i = 1 To Len(sWord)
        If IsNumeric(Mid$(sWord, i, 1)) Then sNewNumber = sNewNumber & Mid$(sWord, i, 1)
    Next i
    ExtractNumeric = sNewNumber
End Function


' test sub

Public Sub TestSub()

    Dim sOldValue As String
    Dim sNewValue As String
   
    sOldValue = "AT1327"
    sNewValue = ExtractNumeric(sOldValue)
    If sNewValue <> "" Then
        sNewValue = Replace(sOldValue, sNewValue, Val(sNewValue) + 1)
    Else
        sNewValue = 1
    End If
   
    MsgBox "From " & sOldValue & vbCrLf & "to " & sNewValue
End Sub

0
 

Author Comment

by:martywal
ID: 17100694
THanks Experts, I ended up going for the split out into two text boxes and concatenating which did the trick.

Will split points ;-)
0
 
LVL 44

Expert Comment

by:GRayL
ID: 17112344
Thanks, glad I could help.
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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now