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

Unique random number on opening form for first time

Have created a section in some code that opens a pre-existing form so that users can input new data. However I'm stuck at this point, basically there is a field in there called invoice number which they need to type in an invoice number (this can be anything, they just have to check it doesnt already exist)

What I would like to happen is when they click on "Add New Enquiry" a unique invoice number is generated and put into the field for them, is that possible?

Code to open the form is as follows

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddNewEnquiry_Click()
  2. On Error GoTo Err_cmdAddNewEnquiry_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "Job"
  8.  
  9.  
  10.     DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
  11.     Forms!Job!STATUS.Value = "ENQUIRY"
  12.  
  13.  
  14. Exit_cmdAddNewEnquiry_Click:
  15.     Exit Sub
  16.  
  17. Err_cmdAddNewEnquiry_Click:
  18.     MsgBox Err.Description
  19.     Resume Exit_cmdAddNewEnquiry_Click
  20.  
  21. End Sub
Jun 5 '15 #1
1 1162
Rabbit
12,516 Expert Mod 8TB
In the table design, set the field as an autonumber and set it to Random.
Jun 5 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: james blair | last post by:
Hi I am generating a random number using random.randint(1,10000000000) Whats the possibility that the numbers generated will be same when generated by 100 users at the same time? Whats the best...
10
by: Sonoman | last post by:
Hi all: I am trying to write a simple program that simulates asking several persons their birth day and it counts how many persons are asked until two have the same birth day. The problem that I...
6
by: VAL | last post by:
How can I make an application form that generates a unique number starting from 1001.?
6
by: Starbuck | last post by:
Hi In VB6 we used the following to create a unique random number - Function longSerial() As Long longSerial = Val((Format$(Int(Rnd * 424) - 212)) + Format$((Timer * 100), "0000000"))...
5
by: vrkamalakar | last post by:
Hi, Can I get a piece of code which can generate a 10 - 15 digit/character of uinque Random Number. The generated random number can contain both characters and digits. Regards, Kamalakar.
9
by: rohitchawla | last post by:
The only way i know is either using combinations like var a=Math.round(Math.random()*1000000); var b=Math.round(Math.random()*1000000); var c=Math.round(new Date().getTime()/1000); d=a+""+b;...
8
by: Anil Gupte | last post by:
I had someone write a random number generator in C# (I am more of a VB programmer) and they came up with the following: public string GetRand(int count) { string number = ""; for (int i=0;...
2
by: mgdvicky | last post by:
I need to generate unique random number to show into the text box value and also perform insert,delete,update operation using java script. I need your solution which is better way using mysql or...
2
by: mgdvicky | last post by:
Can someone tell me a good method for automatically placing a unique random number in a mysql database table when a new record is created.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...

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.