ComboBox o subform to check new record (1 Viewer)

MarRyb

New member
Local time
Today, 12:46
Joined
Dec 2, 2015
Messages
10
Hi everyone,
I’m new to this forum so please be patient with me :).

My database in short:

- I have three tables (StudentsT-StudentID(PK),FName,LName);(StudentListT-StudentListID(PK),StudentID,ClassID);(ClassT-ClassID(PK),CName)

- I have Parent Form ClassF (main form) and StudentListSubF (which is subform of this ClassF), where users can select which students will be in some class-so it will create a list of students. StudentListSubF is a continuous form and students can be selected using cboStudentID combobox.

I’m looking for any way how to do this:

-use cboStudentID combobox (preferably) to check if the children (subform) record is a new record and then show a simple message.

When I enter a new record using cboStudentID combobox, message will be something like “New record entered”. But, when I want to change previous record to another student using same combobox, I’d like to see message “Record updated”.

I tried to put this vba code into my cboStudentID AfterUpdate event. But it shows only “Record updated” message in both cases. My code is:

Code:
Private Sub cboStudentID_AfterUpdate()
    If IsNull(Forms!ClassF!StudentListSubF!StudentID) Then
        MsgBox "New record entered."
    Else
        MsgBox "Record updated."
    End If
End Sub

I can also upload my simple DB for better understanding.

Thank you very much for any help.

Martin
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:46
Joined
Aug 30, 2003
Messages
36,139
You may want to upload the db. Your code would refer to whichever record in the subform has focus, by default the first.
 

MarRyb

New member
Local time
Today, 12:46
Joined
Dec 2, 2015
Messages
10
Thank you Paul.

My database is here.
 

Attachments

  • DB Martin 01.zip
    28 KB · Views: 56

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:46
Joined
Aug 30, 2003
Messages
36,139
Try this test instead:

If Me.NewRecord Then

Not sure why your posts keep getting moderated. I'll try to keep an eye out. It should stop.
 

MarRyb

New member
Local time
Today, 12:46
Joined
Dec 2, 2015
Messages
10
Oh yeah. This works great!

Thank you very much.

Not sure what I'm doing wrong that my posts are moderated though.
 

Users who are viewing this thread

Top Bottom