Click here to Skip to main content
15,915,842 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear all,

For my program I want to use accdb database, created with Access 2016. Now I want to set the textboxes and such so that it will have the same length and property (short text, long text, number or so) as the datafield has.

Is there a way to get this kind of info in visual basic 2017? the table and row name are both known.



Thank,
Hans

What I have tried:

I have search the internet, but can't find any information about this. The only thing I saw was schema info, but this I don't understand exactly.
Posted
Updated 3-Dec-18 8:43am
Comments
Richard MacCutchan 3-Dec-18 14:05pm    
You would need to get the information from the database and modify the properties of the control dynamically. I cannot see any simple way to do this. Or any good reason why you would want to. What would happen if you get a field that is wider than the actual screen?
Member 13039327 3-Dec-18 14:21pm    
Hello Richard,

For the tet boxes, I want them to have the same size as the database. So the user is not typing in 30 characters, while only 20 can be used in the database field.

Or the the user is entering letters, while the database only excepts numbers.

The reason why I want to have this by code is that there are fields that will be used by different tables/fields.

Also do I want to have this by code, that if I change the database field property, the program will automaticaly adjust the size/property of the textfield and I don't need to go thru all those manualy again, to make it to match with the databasefield settings.

Regards,
Hans

1 solution

Just wondering if it's any use: you could use visual basic to set up your tables and fields and then you know what their size is, what format they accept, etc.
But of course if you want to work with an already created database, this may be too much work.
 
Share this answer
 
Comments
Member 13039327 3-Dec-18 14:50pm    
Hello Zsolt,

Indeed I have already the database in Access (accdb). But even if I would create thru VB, that wouldn't change the problem, if I would change the maximum size or property of a field in the database. Then I still need to walk thru whole code to make sure the text length/type will be correct. Or I would need to do by variable. But that I think doesn't work that clean.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900