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

Button for Manual Serial No generate in MS Access

58 32bit
i want to make a button in ms access form for manual data entry serial no.

example

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command984_Click()
  2.     DoCmd.GoToRecord , , acNewRec
  3.     DoCmd.GoToRecord Previous acDataForm, Serial_No = Me.Serial_No.Value + 1
  4. End Sub
how it will be work?

if i entered a data with serial no 1
now going to second serial no 2 by manual clicking a button
so i want to code like go to previous serial no +1 = 2
Sep 22 '20 #1

✓ answered by twinnyfo

Your code would look something like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command984_Click()
  2.     DoCmd.GoToRecord , , acNewRec
  3.     Me.Serial_No = _
  4.         DMax("Serial_No", _
  5.              "YourTableName") + 1
  6. End Sub
Using Domain Aggregate functions (of which DMax() is one of them) is not my favorite, but it should do the job just fine.

Hope this hepps!

6 1238
twinnyfo
3,653 Expert Mod 2GB
ZKAHADI,

If your serial number is strictly numeric, why not just use the AutoNumber Field that is readily available in MS Access?

This is the easiest way.

However, if there is more behind your question, let us know and we can work with that.

Hope that hepps!
Sep 22 '20 #2
isladogs
455 Expert Mod 256MB
Alternatively, if the previous record is the maximum value of that field, you can use =DMax("FieldName", "TableName")+1
Sep 22 '20 #3
ZKAHADI
58 32bit
i dont want to use automatic number because if i delete a record the auto number series gone wrong . for example i entered 5 entries and i delete all then i start from start the auto number starts from 6 not from 1 . and may i start serial no from 100 or others
Sep 23 '20 #4
ZKAHADI
58 32bit
tell me the way how i can use in vba on button .
what i wriate before Equal sign ? =DMax("FieldName", "TableName")+1
Sep 23 '20 #5
twinnyfo
3,653 Expert Mod 2GB
Your code would look something like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command984_Click()
  2.     DoCmd.GoToRecord , , acNewRec
  3.     Me.Serial_No = _
  4.         DMax("Serial_No", _
  5.              "YourTableName") + 1
  6. End Sub
Using Domain Aggregate functions (of which DMax() is one of them) is not my favorite, but it should do the job just fine.

Hope this hepps!
Sep 23 '20 #6
Rabbit
12,516 Expert Mod 8TB
It's rarely a good idea to reuse unique identifiers due to future data integrity issues
Sep 23 '20 #7

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

Similar topics

2
by: willie | last post by:
Hi, I'm writing a program which requires the use of three serial ports and one parallel port. My application has a scanning devices on each port, which I can access fine with pyserial. ...
1
by: Otac0n | last post by:
Is there an standards-compliant way to access the serial port? I need this to potentially work on DOS 6/7 and *nix. Your help would be appreciated.
3
by: Robin | last post by:
Hi all, I'm working with a VB app, using DAO 3.6, that used to generate Access '97 databases using the following code: Set dbsNew = wrkDefault.CreateDatabase(strLPAccessInv, dbLangGeneral,...
13
by: Al the programmer | last post by:
I need to access the serial ports on my webserver from an asp.net page. I have no problem accessing the serial ports from a windows form application, but the code doesn't work in asp.net. I have...
38
by: shussai2 | last post by:
Hi, I am trying to access Serial Port in XP. I am using Dev-C++ IDE that uses Mingw as a compiler. I just want to know how I can open up serial port on COM1 and write some data. I have searched...
0
by: Ima Loozer | last post by:
I would like to be able to remove (or disable) the restore down button on the main Access window. Can someone help me with this please? Thanks, DB
1
by: jamesdel | last post by:
Hi I know how to disable the close button of the main access window. But i am not able to disable the maximum button. Can anyone help me in this regard. It certainly needs API function calling...
0
by: hemant kamble | last post by:
Hi, I am Hemant working on one software which written in QBASIC in that Serial port is access as output mode and write some instruction which dump in printer. So How I can access the serial...
8
by: shalakap | last post by:
hi All!!!!!!!!!! i m trying to place command button on reports in access but it doesnt show the onclick event to connect it with macro or procedure. secondly,i tried to place hyperlink on report...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
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...

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.