473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Formatting in ACCESS 2003

418 256MB
I have a field called MusicCategoryID in a table called tblCategory. It's a number field. MusicCategoryID is a primary key and auto numbered.

I am keeping track of this field in a form called frmCDDetails which is pulling data from a table called tblCDDetails.

when using the Count or DCount function, I get the result that's shown as 41 but I would like to show as 041.

Is it possible to do? Any help anyone can provide will be greatly appreciated. I am a Novice...Thanks.
Aug 18 '08 #1
6 1622
hyperpau
184 Expert 100+
Yes. BUt you can't assign it back to that AutoNumber Field.
only on the Function result of your DCount

Example:

Dim intCount as Integer

intCount = DCount ("MusicCategoryID", "tblCDDetails")
intCount = Format(intCount, "000")

By the way, I think I answered one of your other posts as well.
If it resolves it, please let us know. thanks.
Aug 19 '08 #2
missinglinq
3,532 Expert 2GB
And that code won't produce the desired effect either! You've Dimmed intCount as an Integer

Dim intCount As Integer

you cannot then use the statement

intCount = Format(intCount, "000")

to assign a string value to an Integer, and that's what Format() returns, a string value.

You'd need to add a second variable, a string and do something like this:

Expand|Select|Wrap|Line Numbers
  1. Dim intCount As Integer
  2. Dim strCount As String
  3.  
  4. intCount = DCount("MusicCategoryID", "tblCDDetails")
  5. strCount = Format(intCount, "000")
and then use strCount variable for whatever display purpose you need.

I hope that by "keeping track of this field (MusicCategoryID)" you mean doing the tally we're talking about, and not actually displaying it on your form. Autonumbers should really never been seen by the end users; their purpose in life is to provide a unique identifier for each record. If you want an ID number to display for a each record, and want it to be consecutive and without gaps, you need to use an auto-incrementing hack to generate these numbers.

Welcome to Bytes!

Linq ;0)>
Aug 19 '08 #3
hyperpau
184 Expert 100+
Right. I overlooked that one. :)

And that code won't produce the desired effect either! You've Dimmed intCount as an Integer

Dim intCount As Integer

you cannot then use the statement

intCount = Format(intCount, "000")

to assign a string value to an Integer, and that's what Format() returns, a string value.

You'd need to add a second variable, a string and do something like this:

Expand|Select|Wrap|Line Numbers
  1. Dim intCount As Integer
  2. Dim strCount As String
  3.  
  4. intCount = DCount("MusicCategoryID", "tblCDDetails")
  5. strCount = Format(intCount, "000")
and then use strCount variable for whatever display purpose you need.

I hope that by "keeping track of this field (MusicCategoryID)" you mean doing the tally we're talking about, and not actually displaying it on your form. Autonumbers should really never been seen by the end users; their purpose in life is to provide a unique identifier for each record. If you want an ID number to display for a each record, and want it to be consecutive and without gaps, you need to use an auto-incrementing hack to generate these numbers.

Welcome to Bytes!

Linq ;0)>
Aug 19 '08 #4
MNNovice
418 256MB
I went to the Format box of the text box (called txtCategoryNo) and added 000 without any quotation and it's been working. When the result is 2 digits, it's displaying as 040 (eg) and when it is 3 digits it's showing as 232 (eg).

I am using this textbox to help me manually enter the next serial number.

Let me explain. If my next category is Country and it's a John Denver CD the correct serial number should be: CO.JDA.02.031.0230 (for example)

So when I will enter the MusicCategoryID, instantly the txtCategoryNo will display 031 and when I will enter the ArtistID, it will display 02.

Am I making sense? I wish I could e-mail you a sample DB to help me with it.

Anyway, I saw your response to my other query, I will definitely attempt it.

Thanks for your help.


Right. I overlooked that one. :)
Aug 19 '08 #5
MNNovice
418 256MB
Sorry, it's me again. Just curious. Exactly where do these VBA code supposed to go? on Event Procedure? Format?

/Quote:
Dim intCount as Integer

intCount = DCount ("MusicCategoryID", "tblCDDetails")
intCount = Format(intCount, "000")/Quote


Yes. BUt you can't assign it back to that AutoNumber Field.
only on the Function result of your DCount

Example:

Dim intCount as Integer

intCount = DCount ("MusicCategoryID", "tblCDDetails")
intCount = Format(intCount, "000")

By the way, I think I answered one of your other posts as well.
If it resolves it, please let us know. thanks.
Aug 19 '08 #6
hyperpau
184 Expert 100+
Sorry, it's me again. Just curious. Exactly where do these VBA code supposed to go? on Event Procedure? Format?

/Quote:
Dim intCount as Integer

intCount = DCount ("MusicCategoryID", "tblCDDetails")
intCount = Format(intCount, "000")/Quote
I believe the code I have given you in your other post is already the answer.
You put that on the AfterUpdate Event procedure of your MusicCategoryID and ArtistID comboboxes. and remember, use another variable string.


Expand|Select|Wrap|Line Numbers
  1. Dim intCount as Integer
  2. Dim stCount as String
  3.  
  4. intCount = DCount ("MusicCategoryID", "tblCDDetails")
  5. stCount  = Format(intCount, "000")
Aug 20 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: brAccess | last post by:
I recently installed Access 2003 and immediately noticed problems with applications that work fine in 2000 and XP. I use conditional formatting on continuous forms for a number of reasons. When...
2
by: Colleyville Alan | last post by:
I am using Access and have embedded the ActiveX control Formula One that came with Office 2000. (ver 3.04). I have created and formatted a spreadsheet and now I want to copy the info with...
8
by: Dimitri Furman | last post by:
Given: Access 2002/2003 A subform in datasheet or continuous view, placed on a tab page (this last may or may not matter) Conditional formatting applied to some controls on the subform - format...
4
by: Dave Brydon | last post by:
Access 2003 I have a combo box in my personnel table, which draws its data from a trade code table; the original field in the code table, is numeric, Long Integer, and formatted with 5 zero's . ...
2
by: Neil | last post by:
Is there an editable RTF textbox control which allows the user to apply bold, italic, etc.? I tried the Microsoft Rich Textbox Control, but there doesn't seem to be a way to allow the user to...
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
1
by: dddsssdddsss | last post by:
A comment and a question To anyone who is using conditional formatting, beware that in Access 2007 the color pallette is not the same as the color pallette in Access 2003. So if you have a...
2
by: penaloj | last post by:
I am assembling a database of scientific names, e.g. Acer saccharum Marshall, sugar maple. The first two elements (genus and species) should be italicized in the report, the third element (author)...
2
by: Filips Benoit | last post by:
Dear All, Access 2003 adp on SQL_server 2005 A continious form showing 1 month based on table 'CALENDAR_MONTH_GRID' and fill with a SP. Fields: Companyname, Day1, day2, etc. The value in the...
2
by: robertng90025 | last post by:
I'm having a problem with MS Access 2003 and its conditional formatting. I have textboxes on a continuous form whose left and right margins are set to 0.03 inches. Based on each textbox's...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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...
0
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
0
BarryA
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.