JamieRhysEdwards
New member
- Local time
- Today, 10:23
- Joined
- Mar 26, 2022
- Messages
- 27
Hi All,
In other languages, it's easier and better to be able to use named identifiers instead of their ID's, for example, in Java, you have an Enum:
How would I achieve this with a Lookup table within my code? For example, I'm looking to grab the first two letters of an Asset Tag and if they match that in my look up tables AssetTypePrefix column, I then update my AssetType combo box. However, being new to Access, I'm unsure how to achieve this.
To give a clearer example:
I know the above code is not quite valid but I hope this gives a clearer picture of what I'm looking for.
EDIT:
Just to make this a little clearer (I'm really sorry about this, and I'm not sure if this is possible without making two copies of data). I have a look up table structured like so:
I'd like to get the data from the table and then create some form of VBA type lookup where in I can use a
If this is not something that can be done then I don't mind creating an enum with the titles
In other languages, it's easier and better to be able to use named identifiers instead of their ID's, for example, in Java, you have an Enum:
Code:
public enum AssetType {
Desktop = 0,
Laptop = 1,
MobilePhone = 2,
...
};
How would I achieve this with a Lookup table within my code? For example, I'm looking to grab the first two letters of an Asset Tag and if they match that in my look up tables AssetTypePrefix column, I then update my AssetType combo box. However, being new to Access, I'm unsure how to achieve this.
To give a clearer example:
Code:
Dim AssetTagText As String
AssetTagText = Me.TextAssetTag.Text
If AssetTagText.SubString(0, 2) = AssetType.AssetTypePrefix.LAPTOP Then
' Update AssetType combo box to "Laptop"
End If
I know the above code is not quite valid but I hope this gives a clearer picture of what I'm looking for.
EDIT:
Just to make this a little clearer (I'm really sorry about this, and I'm not sure if this is possible without making two copies of data). I have a look up table structured like so:
ID | AssetType | AssetTypePrefix |
1 | Desktop | DT |
2 | Laptop | LT |
3 | Mobile Phone | MP |
4 | Monitor | M |
5 | Printer | P |
6 | Router | R |
7 | Ethernet Switch | ES |
I'd like to get the data from the table and then create some form of VBA type lookup where in I can use a
AssetType.AssetTypePrefix.LAPTOP/Laptop
type convention which would return ID 2.If this is not something that can be done then I don't mind creating an enum with the titles
AssetType
and AssetTypePrefix
, I'll just have to maintain them if I add further AssetTypes.
Last edited: