473,396 Members | 1,938 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,396 software developers and data experts.

Macros with autonumbering

I am trying to assign an ID number from one table into another table
through forms. Is it possible to create a command button on a form to
feed a new record with this existing number?

For example, I have multiple tables each with its own autonumber.
Each of these numbers are fed into thier appropriate fields in a master
table. A quick visual would be that I've got a table with an
autonumber for field: HA. It is formatted as HA -1, HA -2, etc. I also
have another table with PH - 1, PH -2, etc. and so forth with several
of these tables. Those in turn feed into a master table all with
similar fields but with a new "master" number (autonumber) lableing
each input as MT -1, MT -2, etc.

When I enter data into one of my individual tables and autonumber
labels it as HA - 3, is there a macro for a command button on that form
that will insert that HA - 3 into the master table as a new record,
giving it its own master ID number?

Oct 19 '06 #1
1 2382
Chris,
If I were building the database, i would not use Autonumbers as they can
present difficulties that non autonumeric fields dont.
You will have to write some code.

So, I would, instead, have a separate table "tblMyID"

It would contain two fields
IDType [Text 20]
ID [long]
the data would look something like this

IDType | ID
HA | 1
PH | 34
MT |12

Each time I want a new number, I increment the ID for the relevant IDType

e.g
Docmd.runSql "UPDATE tblMyID SET ID = ID +1 WHERE ID = 'HA'"
Dim iMyNewID as long
iMyNewID = dlookup("ID","tblMyID","ID = 'HA'")

This would return the number 2, so you could then use it anywhere in your
app.
hope that helps

"Chris" <ru******@ipsincorporated.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
>I am trying to assign an ID number from one table into another table
through forms. Is it possible to create a command button on a form to
feed a new record with this existing number?

For example, I have multiple tables each with its own autonumber.
Each of these numbers are fed into thier appropriate fields in a master
table. A quick visual would be that I've got a table with an
autonumber for field: HA. It is formatted as HA -1, HA -2, etc. I also
have another table with PH - 1, PH -2, etc. and so forth with several
of these tables. Those in turn feed into a master table all with
similar fields but with a new "master" number (autonumber) lableing
each input as MT -1, MT -2, etc.

When I enter data into one of my individual tables and autonumber
labels it as HA - 3, is there a macro for a command button on that form
that will insert that HA - 3 into the master table as a new record,
giving it its own master ID number?

Oct 21 '06 #2

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

Similar topics

21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
16
by: mike420 | last post by:
Tayss wrote: > > app = wxPySimpleApp() > frame = MainWindow(None, -1, "A window") > frame.Show(True) > app.MainLoop() > Why do you need a macro for that? Why don't you just write
37
by: michele.simionato | last post by:
Paul Rubin wrote: > How about macros? Some pretty horrible things have been done in C > programs with the C preprocessor. But there's a movememnt afloat to > add hygienic macros to Python. Got any...
2
by: netx | last post by:
I created table with "id" field as "uniqueidentifier" (primary key). I connect via ODBC from MS-Acces. -->>> Don't know how to something like "Autonumber" in MS-Access. Let me know If any...
2
by: Richard | last post by:
Hi, Could anyone help me with the following problem? I created a database for scientific documents, using the usual AutoNumbering for creating Document_ID's (primary key). The Document_ID's...
2
by: N. Graves | last post by:
Hey is there a command like in SQL Transactional that will reset the Autonumber field to the highest number in the found in the field? I developing a access database with a several table that...
33
by: Robert Seacord | last post by:
When writing C99 code is a reasonable recommendation to use inline functions instead of macros? What sort of things is it still reasonable to do using macros? For example, is it reasonable to...
3
by: LeeCaroline | last post by:
Hi, Please forgive me if I use the wrong terminology, I will do the best I can. I am a self-taught Access uses and cueently creating a database for the firm I work for. Part of its function will...
1
by: FRENCH GUY | last post by:
Hi everyone, At the moment, I am working on a database with several tables. Almost every table has her own autonumbering field. So herefore, I am looking for the command that I have to include in...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.