473,804 Members | 3,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting General Number Format in vba

I am appending some new fields to a table in vba and when I append a number
field with is a byte, it does not inherit any format. I want it to be the
General Number format, but it is blank. I have tried to change the format
with the following code, but it does not work. What is wrong with this code
and how can I make that byte number field have the General Number format?

Call
SetPropertyDAO( DBEngine(0)(0). TableDefs("tblC ommendations"). Fields("Year"),
"Format", dbByte, "General Number")

dixie
Mar 28 '07 #1
10 13729
From memory, the Format property is dbText, not dbByte?

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dixie" <di***@dogmail. comwrote in message
news:13******** *****@corp.supe rnews.com...
>I am appending some new fields to a table in vba and when I append a number
field with is a byte, it does not inherit any format. I want it to be the
General Number format, but it is blank. I have tried to change the format
with the following code, but it does not work. What is wrong with this
code and how can I make that byte number field have the General Number
format?

Call
SetPropertyDAO( DBEngine(0)(0). TableDefs("tblC ommendations"). Fields("Year"),
"Format", dbByte, "General Number")

dixie
Mar 28 '07 #2
So how do I set a byte size number field to General Number?

dixie

"Allen Browne" <Al*********@Se eSig.Invalidwro te in message
news:46******** **************@ per-qv1-newsreader-01.iinet.net.au ...
From memory, the Format property is dbText, not dbByte?

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dixie" <di***@dogmail. comwrote in message
news:13******** *****@corp.supe rnews.com...
>>I am appending some new fields to a table in vba and when I append a
number field with is a byte, it does not inherit any format. I want it to
be the General Number format, but it is blank. I have tried to change the
format with the following code, but it does not work. What is wrong with
this code and how can I make that byte number field have the General
Number format?

Call
SetPropertyDAO (DBEngine(0)(0) .TableDefs("tbl Commendations") .Fields("Year") ,
"Format", dbByte, "General Number")

dixie

Mar 28 '07 #3
On Mar 27, 9:35 pm, "Dixie" <d...@dogmail.c omwrote:
So how do I set a byte size number field to General Number?

Hi.

I have no idea what SetPropertyDAO is supposed to be or do, but to
change a local field property this seems to work. This is an example,
not intended to work as is for you. If the Format of the field was not
previously set, it may need to be created with Field.CreatePro perty
first. This changed a byte field from a currency format to general
number.

Function TestFldChange()
Dim db As Database
Dim tbl As TableDef
Dim fld As Field

Set db = CurrentDb
Set tbl = db.TableDefs("t blTestTable")
Set fld = tbl.Fields("Tes tFld")
fld.Properties( "Format") = "General Number"
tbl.Fields.Refr esh

Set fld = Nothing
Set tbl = Nothing
Set db = Nothing

End Function
Mar 28 '07 #4
storrboy, you are right that SetPropertyDAO( ) is not a built-in function.
FYI, it's here:
http://allenbrowne.com/func-DAO.html#SetPropertyDAO

What it does is set the value of the property, creating it if it does not
exist.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"storrboy" <st******@sympa tico.cawrote in message
news:11******** **************@ n76g2000hsh.goo glegroups.com.. .
On Mar 27, 9:35 pm, "Dixie" <d...@dogmail.c omwrote:
>So how do I set a byte size number field to General Number?


Hi.

I have no idea what SetPropertyDAO is supposed to be or do, but to
change a local field property this seems to work. This is an example,
not intended to work as is for you. If the Format of the field was not
previously set, it may need to be created with Field.CreatePro perty
first. This changed a byte field from a currency format to general
number.

Function TestFldChange()
Dim db As Database
Dim tbl As TableDef
Dim fld As Field

Set db = CurrentDb
Set tbl = db.TableDefs("t blTestTable")
Set fld = tbl.Fields("Tes tFld")
fld.Properties( "Format") = "General Number"
tbl.Fields.Refr esh

Set fld = Nothing
Set tbl = Nothing
Set db = Nothing

End Function
Mar 28 '07 #5
Dixie, if you select a field in table design view, in the lower pane, you
see properties such as:
Field Size
Format
...

Are you attempting to set the Field Size to byte?
Or are you attempting to set the Format property to "General Number"?

If you actually want to change the field size to the Byte data type, you
can't do that with DAO. Instead execute a DDL query statemetn like this:
Dim strSql As String
strSql = "ALTER TABLE tblCommendation sALTER COLUMN [Year] BYTE;"
DBEngine(0)(0). Execute strSql, dbFailOnError

If DDL is new, here is an introduction and some examples:
http://allenbrowne.com/func-DDL.html

For a list of the names ot use with the different libraries, see:
Field type reference - names and values for DDL, DAO, and ADOX
at:
http://allenbrowne.com/ser-49.html

And if you really have a field named "Year", this can cause you grief. You
might want to consider renaming the field (and changing the reference in all
queries, forms, reports, macros and code where the name is used.) For a list
of the field names that cause problems, see:
http://allenbrowne.com/AppIssueBadWord.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dixie" <di***@dogmail. comwrote in message
news:13******** *****@corp.supe rnews.com...
So how do I set a byte size number field to General Number?

dixie

"Allen Browne" <Al*********@Se eSig.Invalidwro te in message
news:46******** **************@ per-qv1-newsreader-01.iinet.net.au ...
>From memory, the Format property is dbText, not dbByte?

"Dixie" <di***@dogmail. comwrote in message
news:13******* ******@corp.sup ernews.com...
>>>I am appending some new fields to a table in vba and when I append a
number field with is a byte, it does not inherit any format. I want it
to be the General Number format, but it is blank. I have tried to change
the format with the following code, but it does not work. What is wrong
with this code and how can I make that byte number field have the General
Number format?

Call
SetPropertyDA O(DBEngine(0)(0 ).TableDefs("tb lCommendations" ).Fields("Year" ),
"Format", dbByte, "General Number")

dixie
Mar 28 '07 #6
I thought so. Sorry if I jumped into the middle of a conversation.

Mar 28 '07 #7
You're always welcome.

These are open conversations, so anything you can contribute to help answer
the poster's question is appreciated.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"storrboy" <st******@sympa tico.cawrote in message
news:11******** **************@ y66g2000hsf.goo glegroups.com.. .
>I thought so. Sorry if I jumped into the middle of a conversation.
Mar 28 '07 #8
"Allen Browne" <Al*********@Se eSig.Invalidwro te in
news:46******** **************@ per-qv1-newsreader-01.iinet.net.au :
You're always welcome.

These are open conversations, so anything you can contribute to help
answer the poster's question is appreciated.
I wish to format a cheese sandwich as a general number.

Is this related?

--
lyle fairfield

Ceterum censeo Redmond esse delendam.
Mar 28 '07 #9
Sub Eat(CheeseSandw ich As Byte)
If (CheeseSandwich - Bread) Or (CheeseSandwich - Cheese) Then
MsgBox "Invalid format"
ElseIf Bread Cheese Then
MsgBox "Cheese must be grated"
Else
Nibble CheeseSandwich, Hi
Nibble CheeseSandwich, Lo
MsgBox "Four-matted"
End If
End Sub

There's no foreign key, lyle, so it's not related. :-)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"lyle fairfield" <ly******@yahoo .cawrote in message
news:wI******** *********@read2 .cgocable.net.. .
"Allen Browne" <Al*********@Se eSig.Invalidwro te in
news:46******** **************@ per-qv1-newsreader-01.iinet.net.au :
>You're always welcome.

These are open conversations, so anything you can contribute to help
answer the poster's question is appreciated.

I wish to format a cheese sandwich as a general number.

Is this related?

--
lyle fairfield

Ceterum censeo Redmond esse delendam.
Mar 29 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1959
by: Michael G. Schneider | last post by:
From ASP I create response, which is to be shown as an Excel worksheet in the user's browser (by setting the ContentType and creating a table). This works fine. Does anybody know what to do, if one of the cells should contain a multiline text? I already tried by inserting a <br> inside the <td>. But this won't work. -- Michael G. Schneider
2
3753
by: John Hargrove | last post by:
I'm having trouble setting decimal place values in the results field of a sample management database I'm building for an environmental testing laboratory. The degree of sensitivity varies among test methods; consequently, some results are reported to 2 decimal places, some to 3, etc. The Results subform consists of Test Parameter, Result, Report Unit, Analysis Date, Analyst and other fields. The test parameter control is a drop-down...
1
2540
by: John Marble | last post by:
I looked around for a way to change the format and the decimal setting of a REAL type variable, but I can't seem to be able to find the synthax anywhere. Here is an exemple of what I am doing: ALTER TABLE MAIN ALTER COLUMN sup_visee REAL; It works, it changes the column "sup_visee" which was a String into a REAL. What I want to do too is to be able to set the REAL format to
18
18449
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on a remote update of tables and fields and can't find enough information on these things. Also, how do you index a field in code?
7
7326
by: Philip Wagenaar | last post by:
I use a class to manage tiff's (written by someone else) to splitt multipage tiffs. However, when I run it, it fails, for other people it seems work ok. The method in the class is :public ArrayList SplitTiffImage(string outPutDirectory,EncoderValue format) { string fileStartString=outPutDirectory+"\\"+GetFileNameStartString(_ImageFileName); ArrayList splitedFileNames=new ArrayList(); try
18
1788
by: MLH | last post by:
I have an A97 app that automatically sends eMail using OutLook Express. Each installation requires the user to reconfigure Outlook Express to avoid prompts waiting for them to authorize or deny the email SEND attempts. Theygo to the main Outlook Express window and click Tools, Options. A smaller window opens and they click its 'Security' tab. Then they UNCHECK the box that says "Warn me when other applications try to send mail as me."...
1
6510
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
67
4821
by: James Harris | last post by:
I have a requirement to store timestamps in a database. Simple enough you might think but finding a suitably general format is not easy. The specifics are 1) subsecond resolution - milliseconds or, preferably, more detailed 2) not bounded by Unix timestamp 2038 limit 3) readable in Java 4) writable portably in Perl which seems to mean that 64-bit values are out 5) readable and writable in Python
15
2287
ajhayes
by: ajhayes | last post by:
I posted a question here last week about an ordering database I'm trying to set up, and got some excellent help. So I'm hoping some of you might be able to get me on the right track with another question I've got on the same project. Here's some general info on what I've done so far (For the record, I'm quite a novice at this.): The database I'm setting up is for a small electric utility company to submit orders to the inventory warehouse...
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9572
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.