1cc1d Retrieving auto number value immediately
Sign Up |  Live StatsLive Stats    Articles 37,470| Comments 178,656| Members 19,495, Newest singhajay| Online 453
Home Contact
 (Forgotten?): 
    10 years of Excellence
    For best SPN experience, use Firefox Internet Browser!


                                                                   Your Banner Here!    




Click Here to Register/Sign Up Daily Hukamnama Member Blogs Downloads Website Navigation Help Fonts Tags
Sikh Philosophy Network » Sikh Philosophy Network » Current News » Information Technology » Retrieving auto number value immediately

Retrieving auto number value immediately

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 500 USD, Received: 0 USD (0%)
Please Donate...
     
Related Topics...
Thread Thread Starter Forum Replies Last Post
Auto number - number of digits Eleanor of Aquitaine Information Technology 3 28-Jul-2006 08:42 AM
Auto Increment Number Rusty Information Technology 4 28-Jul-2006 08:32 AM
Auto Number based on another field Jennyjune Information Technology 1 28-Jul-2006 08:18 AM
Changing key from SS# to auto number Jason Information Technology 3 17-Nov-2005 18:02 PM
Set Auto Number to say something other than "Auto Number" naiveprogrammer Information Technology 2 29-Oct-2005 12:35 PM


Tags
retrieving, auto, number, value, immediately
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 28-Jul-2006, 08:16 AM
millie.patel@gmail.com's Avatar millie.patel@gmail.com
Guest
 
Posts: n/a
   
   
Retrieving auto number value immediately

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
Hi,

I am working on a form right now.
I have three tables:
tbl_projects
--projectID
--projectname
--projectdescription
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/10852-retrieving-auto-number-value-immediately.html
--projectmanager
tbl_products
--productID
--productname
--productshortname
--productcategory
tbl_projectproducts
--projectID
--productID

The form is used to enter a project, it has multiple fields (i.e.
project name, project manager, project description).

Only when the project is entered into the database, can I retrieve the
autonumber (primary key) to use to insert values into the
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
projectproducts table.

Is there a way to retrieve the value on the same form? so that i can
enter the product info right away, besides going to a new page?

thanks!



Do you agree or disagree with the writer above? Why not share your immediate thoughts with us! Login Now! or Sign Up Today! to share your views... Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 28-Jul-2006, 08:16 AM
strive4peace's Avatar strive4peace
Guest
 
Posts: n/a
   
   
Re: Retrieving auto number value immediately

Hi Millie,

you can force a save like this:

if me.dirty then me.dirty = false

if you are using the AfterUpdate event of a control (perhaps
projectname), it is obviously dirty, so you can do this:

me.dirty = false
msgbox me.id_controlname

even though you may have more to fill out, you can get the
ID right away (as long as you don't have other fields that
need to be filled before the record saves)

just out of curiosity, why do you need the ID? Why not have
tbl_projectproducts be the recordsource for a subform with
projectID in LinkMasterFields and LinkChildFields?

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day

remote programming and training
strive4peace2006 at yahoo.com

*

millie.patel@gmail.com wrote:
> Hi,
>
> I am working on a form right now.
> I have three tables:
> tbl_projects
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
> --projectID
> --projectname
> --projectdescription
> --projectmanager
> tbl_products
> --productID
> --productname
> --productshortname
> --productcategory
> tbl_projectproducts
> --projectID
> --productID
>
> The form is used to enter a project, it has multiple fields (i.e.
> project name, project manager, project description).
>
> Only when the project is entered into the database, can I retrieve the
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
> autonumber (primary key) to use to insert values into the
> projectproducts table.
>
> Is there a way to retrieve the value on the same form? so that i can
> enter the product info right away, besides going to a new page?
>
> thanks!
>

Reply With Quote
  #3 (permalink)  
Old 28-Jul-2006, 08:16 AM
Graham Mandeno's Avatar Graham Mandeno
Guest
 
Posts: n/a
   
   
Re: Retrieving auto number value immediately

Hi Millie

The autonumber value should be created and assigned the moment you begin to
create a new record. You don't need to wait until it is saved. The earliest
you can get it then is the form's BeforeInsert event.

The most common way to handle a setup like this is with a form and subform.
The form is bound to tbl_projects and the subform to tbl_projectproducts.
The subform should be continuous and needs to contain only a combo box bound
to productID, with its RowSource based on tbl_products. Set both the
LinkMasterFields and LinkChildFields for your subform control to projectID.

Then you can add a new project and select associated products, all from the
one form.
--
Good Luck!

Graham Mandeno [Access MVP]
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
Auckland, New Zealand


wrote in message
news:1149538886.072984.248900@h76g2000cwa.googlegr oups.com...
> Hi,
>
> I am working on a form right now.
> I have three tables:
> tbl_projects
> --projectID
> --projectname
> --projectdescription
> --projectmanager
> tbl_products
> --productID
> --productname
> --productshortname
> --productcategory
> tbl_projectproducts
> --projectID
> --productID
>
> The form is used to enter a project, it has multiple fields (i.e.
> project name, project manager, project description).
>
> Only when the project is entered into the database, can I retrieve the
> autonumber (primary key) to use to insert values into the
> projectproducts table.
>
> Is there a way to retrieve the value on the same form? so that i can
> enter the product info right away, besides going to a new page?
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
>
> thanks!
>



Reply With Quote
  #4 (permalink)  
Old 28-Jul-2006, 08:16 AM
strive4peace's Avatar strive4peace
Guest
 
Posts: n/a
   
   
Re: Retrieving auto number value immediately

In my version, the autonumber value is not available on the
BeforeInsert*, but it is on the BeforeUpdate event...it is
also available on the first control's BeforeUpdate and, of
course, AfterUpdate events

* I thought it would be since, in code, you can get it as
soon as you do .AddNew, but I tried that before I posted
previously and it doesn't apparently work the same way with
the form event -- kinda makes sense though, since it is
before the record is inserted

'~~~~~~

creating a continuous form with checkboxes to pick products

To add on to what Graham said about the form setup.
Handling the records in a continuous subform is, of course,
the way to go. Another thing I often like to do is
something like this:

subform RecordSource:
SELECT pp.projectID, pp.productID,
p.productname, p.productshortname,
p.productcategory,
IIF(isnull(pp.productID),false,true) as chkUsed
FROM tbl_projectproducts as pp
RIGHT JOIN tbl_products as p
ON pp.productID = p.productID
WHERE pp.projectID = forms!mainform!projectID
OR pp.projectID Is Null

chkUsed will be a checkbox at the beginning of each row.
Every product will be listed and the ones that are actually
records in tbl_projectproducts will be checked.

The form itself will not be updateable, but you can use the
click event of the checkbox to append or delete records from
tbl_projectproducts and then requery the form

I am not quite sure about the SQL since I didn't test it --
you may need to make a couple of adjustments
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day

remote programming and training
strive4peace2006 at yahoo.com

*

Graham Mandeno wrote:
> Hi Millie
>
> The autonumber value should be created and assigned the moment you begin to
> create a new record. You don't need to wait until it is saved. The earliest
> you can get it then is the form's BeforeInsert event.
>
> The most common way to handle a setup like this is with a form and subform.
> The form is bound to tbl_projects and the subform to tbl_projectproducts.
> The subform should be continuous and needs to contain only a combo box bound
> to productID, with its RowSource based on tbl_products. Set both the
> LinkMasterFields and LinkChildFields for your subform control to projectID.
>
> Then you can add a new project and select associated products, all from the
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
> one form.

Reply With Quote
  #5 (permalink)  
Old 28-Jul-2006, 08:16 AM
Graham Mandeno's Avatar Graham Mandeno
Guest
 
Posts: n/a
   
   
Re: Retrieving auto number value immediately

Hi Crystal

> chkUsed will be a checkbox at the beginning of each row. Every product
> will be listed and the ones that are actually records in
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
> tbl_projectproducts will be checked.
>
> The form itself will not be updateable, but you can use the click event of
> the checkbox to append or delete records from tbl_projectproducts and then
> requery the form


This is precisely what I've been doing since Access 2.0.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852

Who needs "complex data" eh?

Cheers,
Graham


Reply With Quote
  #6 (permalink)  
Old 28-Jul-2006, 08:16 AM
millie.patel@gmail.com's Avatar millie.patel@gmail.com
Guest
 
Posts: n/a
   
   
Re: Retrieving auto number value immediately

thanks all! all your messages were very very helpful!



Graham Mandeno wrote:
> Hi Crystal
>
> > chkUsed will be a checkbox at the beginning of each row. Every product
> > will be listed and the ones that are actually records in
> > tbl_projectproducts will be checked.
> >
> > The form itself will not be updateable, but you can use the click event of
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
> > the checkbox to append or delete records from tbl_projectproducts and then
> > requery the form

>
> This is precisely what I've been doing since Access 2.0.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
>
> Who needs "complex data" eh?
>
> Cheers,
> Graham


Reply With Quote
  #7 (permalink)  
Old 28-Jul-2006, 08:17 AM
strive4peace's Avatar strive4peace
Guest
 
Posts: n/a
   
   
Re: Retrieving auto number value immediately

you're welcome, Millie

if you are going to use the checkboxes, you should add this
field to tbl_projectproducts

ProjProdID, autonumber

this will give you a unique way to identify each record

in the recordset, you can use this:

IIF(IsNull(ProjProdID),0,ProjProdID)

and then, if ProjProdID = 0, you know you need to add the
record when the checkbox is ticked, or if >0, remove it when
the checkbox is ticked ... then, after you issue SQL:

currentdb.tabledefs.refresh
DoEvents
me.chkUsed.requery


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day

remote programming and training
strive4peace2006 at yahoo.com

*

millie.patel@gmail.com wrote:
> thanks all! all your messages were very very helpful!
>
>
>
> Graham Mandeno wrote:
>
>>Hi Crystal
>>
>>
>>>chkUsed will be a checkbox at the beginning of each row. Every product
>>>will be listed and the ones that are actually records in
>>>tbl_projectproducts will be checked.
>>>
>>>The form itself will not be updateable, but you can use the click event of
>>>the checkbox to append or delete records from tbl_projectproducts and then
>>>requery the form

Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
>>
>>This is precisely what I've been doing since Access 2.0.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
>>
>>Who needs "complex data" eh?
>>
>>Cheers,
>>Graham

>
>

Reply With Quote
  #8 (permalink)  
Old 28-Jul-2006, 08:17 AM
strive4peace's Avatar strive4peace
Guest
 
Posts: n/a
   
   
Re: Retrieving auto number value immediately

Hi Graham,

I love Access! I, too, have been using it since 2.0 -- and
continue to learn great new things all the time!

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852

remote programming and training
strive4peace2006 at yahoo.com

*

Graham Mandeno wrote:
> Hi Crystal
>
>
>>chkUsed will be a checkbox at the beginning of each row. Every product
>>will be listed and the ones that are actually records in
>>tbl_projectproducts will be checked.
>>
>>The form itself will not be updateable, but you can use the click event of
>>the checkbox to append or delete records from tbl_projectproducts and then
>>requery the form

>
>
> This is precisely what I've been doing since Access 2.0.
>
> Who needs "complex data" eh?
>
> Cheers,
> Graham
>
>

Reply With Quote
  #9 (permalink)  
Old 28-Jul-2006, 08:17 AM
millie.patel@gmail.com's Avatar millie.patel@gmail.com
Guest
 
Posts: n/a
   
   
Re: Retrieving auto number value immediately

  Donate Today!  
i could have subforms -- but was just wondering if there was a
different way of doing it -- im not too familiar with using subforms
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10852

but all your information was helpful!
thanks!

strive4peace wrote:
> Hi Millie,
>
> you can force a save like this:
>
> if me.dirty then me.dirty = false
>
> if you are using the AfterUpdate event of a control (perhaps
> projectname), it is obviously dirty, so you can do this:
>
> me.dirty = false
> msgbox me.id_controlname
>
> even though you may have more to fill out, you can get the
> ID right away (as long as you don't have other fields that
> need to be filled before the record saves)
>
> just out of curiosity, why do you need the ID? Why not have
> tbl_projectproducts be the recordsource for a subform with
> projectID in LinkMasterFields and LinkChildFields?
>
> Warm Regards,
> Crystal
> Microsoft Access MVP 2006
>
> *
> Have an awesome day
>
> remote programming and training
> strive4peace2006 at yahoo.com
>
> *
>
> millie.patel@gmail.com wrote:
> > Hi,
> >
> > I am working on a form right now.
> > I have three tables:
> > tbl_projects
> > --projectID
> > --projectname
> > --projectdescription
> > --projectmanager
> > tbl_products
> > --productID
> > --productname
> > --productshortname
> > --productcategory
> > tbl_projectproducts
> > --projectID
> > --productID
> >
> > The form is used to enter a project, it has multiple fields (i.e.
> > project name, project manager, project description).
> >
> > Only when the project is entered into the database, can I retrieve the
> > autonumber (primary key) to use to insert values into the
> > projectproducts table.
> >
> > Is there a way to retrieve the value on the same form? so that i can
> > enter the product info right away, besides going to a new page?
> >
> > thanks!
> >


Reply With Quote
   Click Here to Donate Now!

Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools Search
Search:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

» Active Discussions
Thought of the Moment!
Today 00:06 AM
116 Replies, 6,101 Views
English Sri Guru Granth Sahib Ji Translations
Yesterday 23:30 PM
6 Replies, 88 Views
Can Sikhs worship...
Yesterday 23:17 PM
15 Replies, 156 Views
Sikh Philosophy Network...
Yesterday 22:26 PM
16 Replies, 765 Views
Sikh Spokesman (ਪੰਜਾਬੀ...
Yesterday 21:25 PM
256 Replies, 6,069 Views
Difference in Bowing...
By Kamala
Yesterday 15:08 PM
11 Replies, 260 Views
What Really Happened on...
Yesterday 12:46 PM
13 Replies, 222 Views
Free Online Gurbani...
Yesterday 03:56 AM
13 Replies, 4,339 Views
English Sri Guru Granth...
Yesterday 03:51 AM
5 Replies, 171 Views
Edward Snowden: the...
Yesterday 03:34 AM
3 Replies, 186 Views
Rozana Reports (ਪੰਜਾਬੀ...
Yesterday 03:23 AM
407 Replies, 9,442 Views
What Is Difference...
18-Jun-2013 09:18 AM
6 Replies, 183 Views
First There is Water by...
By Ishna
18-Jun-2013 05:03 AM
3 Replies, 192 Views
Cooking Without Alcohol
18-Jun-2013 02:12 AM
12 Replies, 203 Views
Learning from Baba...
18-Jun-2013 01:38 AM
0 Replies, 312 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.3
All times are GMT +6.5. The time now is 00:10 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 0.56942 seconds with 32 queries
0