When you use a autonumber field in your table, then the control on your form will show "(autonumber)" as long as you have not started to type anything.
Now I can't use autonumber in this case (Numbers MUST be sequential) so I will use a number and keep track of it through code. (I know how to do this, so don't comment on that:P) However, I would like the control to display "(AutoID)" until a value is assigned to the field. Does anyone know of a way to accomplish this?
If there is no std. way I think I will simply make a label on top of the control and show/hide it as needed.
Hi Smiley. As long as the textbox concerned is bound to a numeric field and not text you can use the textbox's format property to accomplish this, by setting the format for Null to be the string literal "(Auto ID)".
The property setting is as follows: 0;-0;0;"(Auto ID)"
The format sections separated by semi-colons are: format to apply to positive numbers, negative numbers, zero values, and null values.
I use this property frequently to display custom messages for boolean values, setting the enabled property false and locked true to prevent users from clicking into the field (whereupon they would be shown the actual value underlying the formatted presentation).
-Stewart
4 2415
Hi Smiley. As long as the textbox concerned is bound to a numeric field and not text you can use the textbox's format property to accomplish this, by setting the format for Null to be the string literal "(Auto ID)".
The property setting is as follows: 0;-0;0;"(Auto ID)"
The format sections separated by semi-colons are: format to apply to positive numbers, negative numbers, zero values, and null values.
I use this property frequently to display custom messages for boolean values, setting the enabled property false and locked true to prevent users from clicking into the field (whereupon they would be shown the actual value underlying the formatted presentation).
-Stewart
Nice and very simple. I can also see it being very usefull for boolean values. What I've done before is to create a table as lookup table to get my display to look good. One more question, can you in the same format string specify that the string literal "(AutoID)" should be in italics, but the number should be normal?
Hi Smiley. 'Fraid you can't specify character formatting in the format string, but if you are using A2007 or above it can be done using conditional formatting along with the formatted field text, setting the format to italic for expression IsNull([your field name]). My test of it shows that it is not really much differentiated by the slanted characters, but it does work.
You could also change the background colour (say) that way if you wanted, to make it clear that it is a value not yet set.
-Stewart
Thank you for your reply.
In the end, I've decided to go with a label, and show/hide it depending on whether its a newrecord or not.
I will however use your format trick for boolean values, I am sure that will come in handy!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jan Hendrickx |
last post by:
Hi all,
I use (something like) following code to add new records to a database,
but it doesn't work!!!
I need to know the value of an AutoNumber-field when I add the record.
Why doesn't it...
|
by: Mike Wiseley |
last post by:
You can create a query in the SQL view that adds a new column to a table.
For example, to add a new text field named X10, you use the following
language:
Alter Table MyTargetTable1
Add Column...
|
by: ben.werdmuller |
last post by:
Hi,
Is there an easy way in ASP/VBscript to grab an autonumber (primary
key) field just after an SQL insert? This is probably easy, but I'm
stuck ..
Cheers.
|
by: S. van Beek |
last post by:
Dear reader,
By append a new record to a table I always expect the next higher value in
the range of the autonumber field.
But sometimes if I have deleted same records from a table the...
|
by: HS1 |
last post by:
Hello
I have a table in Access Database. This table has a AutoNumber field. I use
a DataGrid to show that table
When I insert a new record in for this table using a DataGrid, there is a...
|
by: minjie |
last post by:
I need to upgrade a MS Access database (Version 2002) with a script
only, i.e., via SQL statement, not via Access GUI, and I'm having
trouble defining an AutoNumber field. I got an exception error...
|
by: gtwannabe |
last post by:
I'm having a problem with a form that uses AutoNumber as the primary
key. I have an Abort button to delete the current record and close the
form. If AutoNumber is assigned, the code executes a...
|
by: jmar |
last post by:
I'm hoping someone out there can give me a little guidance. I have
an Access Database "Customer.MDB" with a table "CustInfo" that
has the following design:
Field: DataType
CustID AutoNumber...
|
by: BMF |
last post by:
Howdy,
I am mainly a MySQL user but I have been playing with Access 07 a little bit recently. I created a database with 3 tables.
Table ID ---
userID -- AutoNumber
UserInfo -...
|
by: Richard Sherratt |
last post by:
I've inherited a system that was designed by someone with no
understanding of database design. From the logical design point of
view, there is no logical design. The physical design is a nightmare....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |