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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for new record on subform

Status
Not open for further replies.

Castanz

Programmer
Apr 5, 2002
61
US
I made some code that works great on a single form, but doesn't work on the subform. The code checks to see if the current record is new.

Private Sub Form_Current()
Dim intnewrec As Integer
intnewrec = Forms("Training").NewRecord

If intnewrec = True Then
Course_not_selected = True
Else
Course_not_selected = False
End If
MsgBox Course_not_selected

Training is the subform. Edit_Course is my main form. If I try the same code from Edit Course I get "Can't find form 'Training'" If I try this from Training it works great. Can anyone help? Thanks in advance. This site is great and I have found lots of help here.
 
I have tried changing the line to:
intnewrec = Forms![Edit_Course]![Training].NewRecord
but that doesn't work.
 
It looks like I was making this problem harder than it was. I just found the answer. Change the code to:

If Me.NewRecord Then
Course_not_selected = True
Else
Course_not_selected = False
End If
MsgBox Course_not_selected

I didn't need any other functions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top