Hi There,
I amcurrently building a MDI application.
Both my Add and Edit screen use a form called frmStaffDetails.
On load, this form is redefined as 'AddStaffChild' and 'EditStaffChild' dependant on which menu item is selected.
I've defined the CurrentForm as Form.ActiveForm.ActiveMdiChild.
Within a module I am checking the text withincertain textboxes. So for example here I am checking a name has been inputted. If it has, then I will allow the record to be saved.
Public
Sub CheckStaffSave()
If
Not CurrentForm.Controls("txtFirstName").Text = "" Then
MsgBox(
"You are about to enter this record into the database do you wish to continue?", MsgBoxStyle.YesNoCancel)
If vbOK Then
SaveStaffRecord()
ClearStaffBoxes()
Else
Exit Sub
End If
The problem I am having is that this code works perfectly if the textbox control is not within a Tab Control. As soon as I put it in a tab page I get the error.
"Referenced object item has a value of Nothing"
Also if I reference it directly for example
If Not AddStaffChildForm.txtFirstName.Text = ""
this works fine too, but i want it to be more genric so I can use it for my edit screen as well.
How can I define a control within a Tab Control from a module (or any otherway to declare a public sub).
Cheers