OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Creating A Form With A Unique Number

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer
View previous topic :: View next topic  
Author Message
mtntimes
Newbie
Newbie


Joined: 14 Aug 2012
Posts: 2

PostPosted: Tue Aug 14, 2012 12:46 pm    Post subject: Creating A Form With A Unique Number Reply with quote

I've been tasked to try and create a form that will generate a unique 5 digit code each time it is used and this form will have multiple users. I can create the rest of the form no problem, but I'm stuck on how to handle the unique form number situation. I'm beginning to wonder if it is even possible. Any suggestions and advice will be greatly appreciated. Even stating it's not possible will be appreciated so that I can stop trying to figure this out.
Back to top
View user's profile Send private message
floris_v
Moderator
Moderator


Joined: 12 Jul 2007
Posts: 4791
Location: Netherlands

PostPosted: Tue Aug 14, 2012 1:10 pm    Post subject: Reply with quote

You can do it - if you already managed the rest. You will need a separate file where you record any numbers already used. You can use a random generator to get a random number (maybe you need to make a few calls to get a five digit code), then you need to test if that number was already used, if so, generate another one and so on. When you have found an unused code, write that to that file.
Use Rnd and Randomize to generate the random numbers. To get random numbers in the range 0..99, use Int (Rnd*100).
_________________
LibreOffice 3.6.3; OOo 3.4.1 on Windows Vista
Join the Official community forum - in several languages, including Nederlandstalig forum
Back to top
View user's profile Send private message
Corfy
Moderator
Moderator


Joined: 14 Jun 2005
Posts: 1117
Location: Near Indianapolis, IN, USA

PostPosted: Tue Aug 14, 2012 1:18 pm    Post subject: Reply with quote

Stupid question... does it need to be a random five-digit number?

It occurred to me that sequential five digit numbers would be fairly easy to make based on the unique ID in the table.

00001
00002, etc.

Of course, that might not fit in with what you are trying to do. And I'm hardly an expert when it comes to databases.
_________________
Laugh at life or life will laugh at you.
Back to top
View user's profile Send private message Visit poster's website
floris_v
Moderator
Moderator


Joined: 12 Jul 2007
Posts: 4791
Location: Netherlands

PostPosted: Tue Aug 14, 2012 1:20 pm    Post subject: Reply with quote

Crap, I never thought of that. Embarassed
_________________
LibreOffice 3.6.3; OOo 3.4.1 on Windows Vista
Join the Official community forum - in several languages, including Nederlandstalig forum
Back to top
View user's profile Send private message
mtntimes
Newbie
Newbie


Joined: 14 Aug 2012
Posts: 2

PostPosted: Wed Aug 15, 2012 4:14 am    Post subject: Reply with quote

Great suggestions so far. I need the form to start with a specific 5 digit number then go sequential after that. Keep in mind their will be multiple users using this form from different computers and I need a way to guarantee them that each form will always have a unique code on it. Perhaps to accomplish that I'll need to create the form so that it can be placed online and emailed through our company server somehow. That's a questions for our IT guy I suppose. If I can just get the form created and figure out how to program the 5 digit number in I'll let them handle the technical end. I also need to know how to tell the form to start at a specific number.

All your help is greatly appreciated.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group