Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What does this mean?'

Status
Not open for further replies.

xdia

MIS
May 23, 2002
20
0
0
US
Someone please explain what this code do?

Sub NewRec()
Dim LastNum As Long
Dim NewLastNum As Long
DoCmd.GoToRecord , , acLast
LastNum = CLng(Me![RECORD #])
NewLastNum = LastNum + 1
DoCmd.GoToRecord , , acNewRec
Me![RECORD #] = NewLastNum

End Sub

I use this for 3 forms and I get error in 2 place and one is ok but seems like everything is same to me.

Thanks for help thank you.
 
when debug this line is highlighted
LastNum = CLng(Me![RECORD #])

what is Me!?
 
Error is saying that one of the value is null but it is for different form. How do I declare it for different form?

because I just copied the vba from different form and recycling it on another one.

Thanks,
 
from the statments, I assume that "[RECORD #]" is a textbox on the form(s) where this does work, and no such control exists on the other form(s).

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
it seems that code is creating an autonumber for indexing new records. It finds the last record number and then goes to a new record and writes and new record number based on old record number plus 1.

me!= a variable that represents the name of your active Form or Report. Its used so that you don't have to type Forms!MyForm! or Reports!MyReports all the time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top