473,666 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make a counter field in Access 2.0 using something like Set MyField = MyTableDef.Crea teField("Segmen t", DB_LONG)

MLH
I would like to modify the following Access Basic code in Access 2.0
app so the [Segment] field would an automatic counter-type field.

Dim DefaultWorkspac e As WorkSpace, CurrentDatabase As Database
Dim MyTableDef As TableDef
Dim MyField As Field
Set DefaultWorkspac e = DBEngine.Worksp aces(0)
Set CurrentDatabase = DefaultWorkspac e.Databases(0)
Set MyTableDef = CurrentDatabase .CreateTableDef ("tblTempTable" )
Set MyField = MyTableDef.Crea teField("Segmen t", DB_LONG)
MyTableDef.Fiel ds.Append MyField
Set MyField = MyTableDef.Crea teField("Segmen tText", DB_MEMO)
MyTableDef.Fiel ds.Append MyField
CurrentDatabase .TableDefs.Appe nd MyTableDef

Can anyone tell me how to modify the above code so [Segment] will
be a counter field upon creation?
Nov 13 '05 #1
2 3940
With Access 97, you'd use

Set MyTableDef = CurrentDatabase .CreateTableDef ("tblTempTable" )
Set MyField = MyTableDef.Crea teField("Segmen t", dbLong)
MyField.Attribu tes = MyField.Attribu tes + dbAutoIncrField
MyTableDef.Fiel ds.Append MyField

Unfortunately, I don't have Access 2 handy, so I can't check what the
equivalent to dbAutoIncrField would be in Access 2.0. dbAutoIncrField is
equal to 16. See if that works.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"MLH" <CR**@NorthStat e.net> wrote in message
news:ql******** *************** *********@4ax.c om...
I would like to modify the following Access Basic code in Access 2.0
app so the [Segment] field would an automatic counter-type field.

Dim DefaultWorkspac e As WorkSpace, CurrentDatabase As Database
Dim MyTableDef As TableDef
Dim MyField As Field
Set DefaultWorkspac e = DBEngine.Worksp aces(0)
Set CurrentDatabase = DefaultWorkspac e.Databases(0)
Set MyTableDef = CurrentDatabase .CreateTableDef ("tblTempTable" )
Set MyField = MyTableDef.Crea teField("Segmen t", DB_LONG)
MyTableDef.Fiel ds.Append MyField
Set MyField = MyTableDef.Crea teField("Segmen tText", DB_MEMO)
MyTableDef.Fiel ds.Append MyField
CurrentDatabase .TableDefs.Appe nd MyTableDef

Can anyone tell me how to modify the above code so [Segment] will
be a counter field upon creation?

Nov 13 '05 #2
MLH
Hey, thanks much for the lead. A minor adjustment for Access 2.0
which uses DB_AUTOINCRFIEL D as opposed to dbAutoIncrField .
I owe you one.

xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxx

On Sat, 9 Oct 2004 19:50:20 -0400, "Douglas J. Steele"
<NOSPAM_djsteel e@NOSPAM_canada .com> wrote:
With Access 97, you'd use

Set MyTableDef = CurrentDatabase .CreateTableDef ("tblTempTable" )
Set MyField = MyTableDef.Crea teField("Segmen t", dbLong)
MyField.Attribu tes = MyField.Attribu tes + dbAutoIncrField
MyTableDef.Fiel ds.Append MyField

Unfortunatel y, I don't have Access 2 handy, so I can't check what the
equivalent to dbAutoIncrField would be in Access 2.0. dbAutoIncrField is
equal to 16. See if that works.


Nov 13 '05 #3

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

Similar topics

5
16950
by: Jim West | last post by:
Could someone please explain to me why the code segment class FOO { public: double *begin(); }; void bar(const FOO &foo) { foo.begin(); }
4
1989
by: Max | last post by:
Hello everyone, and thank you in advance for all of your help! I have a tblPrint table in Access 2002. Its structure is as follows: tblPrint ------------------ Name, Text Address1, Text Address2, Text City, Text
4
1193
by: Hrishi R | last post by:
Hi: The following ASP.NET code segment throws an "Object reference not set to an instance of an object" exception. ------------------ Public Sub Page_Load(Source As Object, E As EventArgs) Dim viewCount As Integer If ViewState("viewCount").ToString() = "" Then
16
10514
by: John Kelsey | last post by:
Back in the "old" days with C, I used to do something like... struct { char Description; float price; } Items = { {"Apple", 1.99}, {"Banana", 2.04}
43
2713
by: markryde | last post by:
Hello, I saw in some open source projects a use of "!!" in "C" code; for example: in some header file #define event_pending(v) \ (!!(v)->vcpu_info->evtchn_upcall_pending & \ !(v)->vcpu_info->evtchn_upcall_mask) whereas evtchn_upcall_pending is of type unsigned char (and also evtchn_upcall_mask is of type unsigned char).
3
2746
by: R. P. | last post by:
Subject: XSLT to transform a flat XML file into a structured text file I have an XML file that lists the PDF file segment names and titles of a larger document and looks something like this: <DOCUMENT> ...... ...... some lead elements ...... <SEGMENT_LIST>
0
5587
by: minapatel | last post by:
I have the following procedure CREATE OR REPLACE procedure FOL_PURGE_CASES as /* type "SET SERVEROUTPUT ON" in sqlplus to debug !! */ cursor all_cases is cursor all_cases is select c.id00_warehouse, c.id00_case_nbr, c.id00_status_flag, c.id00_dlm from phpick00 a, chcart00 b, idcase00 c
11
1762
by: letz | last post by:
Hi, We have a class whose objects are to be allocated in shared memory. To do that a ShmManager base class is defined so that operator new and delete are redefined to allocate segments in shared memory. A typical class "Foo" then inherit from ShmManager to have get this behaviour. class ShmManager {
4
9845
by: FullBandwidth | last post by:
I have been perusing various blogs and MSDN pages discussing the use of event properties and the EventHandlerList class. I don't believe there's anything special about the EventHandlerList class in this context, in fact some articles from pre-2.0 suggest using any collection class of your choice. So my questions focus more on the syntax of event properties provided by the "event" keyword in C#. (Disclaimer - I am a C++ programmer working...
0
8444
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
8869
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4198
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
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
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
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
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.