Button to add a new record (1 Viewer)

naobao

Registered User.
Local time
Yesterday, 17:51
Joined
Feb 13, 2014
Messages
76
Hi,

I want to use a form button to automatic create a new data record,
need to use this format in the table field...
date + three digit serial no...
everyday from 20170110-001 to 20170110-999
 

Ranman256

Well-known member
Local time
Yesterday, 20:51
Joined
Apr 9, 2015
Messages
4,337
you really shouldnt do it this way. Instead just create a Date/time field set for General date. (both date and time stamp) This eliminates the need for code and does the exact same affect.
BUT, if you want the code version:
turn on the toobar wizard,
grab a button from toolbar, place on form,
select the action, ADD NEW RECORD
button will create
select button, property events, on click event
click the ellipsis button on the on click event
view the code that adds new record,
after the 'add new code' add code to create the serial no.

Code:
vDat = format(Date,"yyyymmdd")
vNum = nz(DMax([serial]","table","[serial] like " & vDat & "*"))

txtBox = vDat & "-" & vNum + 1
 

naobao

Registered User.
Local time
Yesterday, 17:51
Joined
Feb 13, 2014
Messages
76
Thank you very much!!
 

naobao

Registered User.
Local time
Yesterday, 17:51
Joined
Feb 13, 2014
Messages
76
Sorry ...

I still not understand how to do,
can you give me a sample file?

Many Thanks!!
 

Users who are viewing this thread

Top Bottom