Solved Add a number after a Left() (1 Viewer)

PatAccess

Registered User.
Local time
Today, 17:45
Joined
May 24, 2017
Messages
284
Hello Guys,
I am trying to create an ID based on the first 4 characters of an input. However, I would like to add a number to it each time starting with 1. How can I do that?
Here is what I have so far
Code:
'Get the new Provider name
    strNewProvider = InputBox("Please type a new Provider Name", "New Provider")
    
    'Create the ID with the Left function
    strCreateID = Left(strNewProvider, 4)
    strCreateID = strCreateID
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:45
Joined
Sep 21, 2011
Messages
14,369
Store the number, which to start with will be zero, then use DMax()+1 ?

Personally, I'd use an autonumber?
 

PatAccess

Registered User.
Local time
Today, 17:45
Joined
May 24, 2017
Messages
284
Store the number, which to start with will be zero, then use DMax()+1 ?

Personally, I'd use an autonumber?
I wanted to use an autonumber but How do I concatenate it with my substring?
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:45
Joined
Sep 21, 2011
Messages
14,369
You do not.
The autonumber is your key to link to all tables.
You can make up your own visual 'key' if a user can use that to find a record, but in reality the real key in the system is the autonumber.
My first reply would still work for your dummy/visual key.
Eg
Smit01
Smit02
Smit03
 

PatAccess

Registered User.
Local time
Today, 17:45
Joined
May 24, 2017
Messages
284
You do not.
The autonumber is your key to link to all tables.
You can make up your own visual 'key' if a user can use that to find a record, but in reality the real key in the system is the autonumber.
My first reply would still work for your dummy/visual key.
Eg
Smit01
Smit02
Smit03
So I know how to create the previous the smit01 smit02 etc. But Can I also create something similar within VBA for an entry form? and my question is if yes? how do I use the Left() and the autonumber feature? so if I want to replace "smit" here with Left(string,4)
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:45
Joined
Sep 21, 2011
Messages
14,369
They are two separate fields.
The autonumber is generated by ACcess, you do not need to worry about that, just ensure it used to link to child records etc.
For you Left(,4) and number do as I mentioned in post #2.

So even if you have Smit03 and then want an Evan, that will be Evan04 ? Otherwise you will need to store the string value and the number then look for Evan and not having any (yet), you create the first as Evan01, then the next will be Evan02 etc.
If you are going to have more than 99, then you need to increase the size of the number field.
 

PatAccess

Registered User.
Local time
Today, 17:45
Joined
May 24, 2017
Messages
284
They are two separate fields.
The autonumber is generated by ACcess, you do not need to worry about that, just ensure it used to link to child records etc.
For you Left(,4) and number do as I mentioned in post #2.

So even if you have Smit03 and then want an Evan, that will be Evan04 ? Otherwise you will need to store the string value and the number then look for Evan and not having any (yet), you create the first as Evan01, then the next will be Evan02 etc.
If you are going to have more than 99, then you need to increase the size of the number field.
Ok Thank you
 

Users who are viewing this thread

Top Bottom