Main Form, Sub-Form

S

Sue Wilkes

I have a main form (ALLFORM) the control source is the main table (GenReg).
I have a table Hyperlink which contains a hyperlink field. The tables are
linked using RegisterNumber (Primary Key). On my main form I have a SaveRec
button which does not enable until all the fields are completed. I would
like to include the hyperlink field in the validation so that the button on
the main form does not enable unless the fields on the main form AND the
hyperlink field on the subform have been completed. I am using a fucntion
and the afterupdate event on the fields as given below. Any help on this
would be greatfully appreciated, Regards Sue

Function CheckFieldIN() As Boolean
If Me.AddNewRecIN.Enabled = True And IsNull(Me.RegisterNumber) Or
IsNull(Me.DateReceived) Or IsNull(Me.ReceivedFrom) Or IsNull(Me.DeptCode) Or
IsNull(Me.Designation) Or IsNull(Me.Subject) Or IsNull(Me.CompanyName) Or
IsNull(Me.Hyperlink1) Then
CheckFieldIN = False
Else
CheckFieldIN = True
End If
End Function
//////////////////////////////////
Function CheckFieldOUT() As Boolean
If Me.AddNewRecOUT.Enabled = True And IsNull(Me.RegisterNumber) Or
IsNull(Me.DateSent) Or IsNull(Me.SentTo) Or IsNull(Me.DeptCode) Or
IsNull(Me.Designation) Or IsNull(Me.Subject) Or IsNull(Me.CompanyName) Or
IsNull(Me.Hyperlink1) Then
CheckFieldOUT = False
Else
CheckFieldOUT = True
End If
End Function
///////////////////////
Private Sub CompanyName_AfterUpdate()
If Me.AddNewRecIN.Enabled = True Then
Me.SaveAddNewRec1.Enabled = CheckFieldIN
Else
Me.SaveAddNewRec2.Enabled = CheckFieldOUT
End If

End Sub
 
W

Wayne-I-M

Hi Sue

I may be wrong but it may be a good idea to add the hyperlink "checker" for
the subform as a seperate item (I have given 2 codes below to allow or not).
The reason for this is that you can then ask for the hyperlink "if" it's
avaiable - this still allow the button to opertate without it but will tell
the user its meant to be there.

If (IsNull(Forms!MainFormName!SubFormName.Form!HyerlinkField)) Then
MsgBox "Some message here", vbOKOnly, "Box title"
End If

This would be added to your main function like this

__________________________________________

This would "allow" the button to function

Function CheckFieldOUT() As Boolean
If Me.AddNewRecOUT.Enabled = True And IsNull(Me.RegisterNumber) Or
IsNull(Me.DateSent) Or IsNull(Me.SentTo) Or IsNull(Me.DeptCode) Or
IsNull(Me.Designation) Or IsNull(Me.Subject) Or IsNull(Me.CompanyName) Or
IsNull(Me.Hyperlink1)
End If

Then
CheckFieldOUT = False
Else
CheckFieldOUT = True
End If

If (IsNull(Forms!MainFormName!SubFormName.Form!HyerlinkField)) Then
MsgBox "Some message here", vbOKOnly, "Box title"
End If

End Function

__________________________________________

This would "stop" the button functioning - (there is no message box)


Function CheckFieldOUT() As Boolean
If Me.AddNewRecOUT.Enabled = True And IsNull(Me.RegisterNumber) Or
IsNull(Me.DateSent) Or IsNull(Me.SentTo) Or IsNull(Me.DeptCode) Or
IsNull(Me.Designation) Or IsNull(Me.Subject) Or IsNull(Me.CompanyName) Or
IsNull(Me.Hyperlink1)
Or (IsNull(Forms!MainFormName!SubFormName.Form!HyerlinkField)
End If

Then
CheckFieldOUT = False
Else
CheckFieldOUT = True
End If
End Function



Hope this helps
 
S

Sue Wilkes

Hi Wayne, Thank you for your reply, I tried the following code (placed on the
main form) and all works well until I move the focus to the subform to enter
the hyperlink1 at which point the button enables. Do I need to add code to
the Hyperlink1 field on the subform, if so could you please give me some
guidance on this. Many thanks Sue
/////////////////////
Function CheckFieldIN() As Boolean
If Me.AddNewRecIN.Enabled = True And IsNull(Me.RegisterNumber) Or
IsNull(Me.DateReceived) Or IsNull(Me.ReceivedFrom) Or IsNull(Me.DeptCode) Or
IsNull(Me.Designation) Or IsNull(Me.Subject) Or IsNull(Me.CompanyName) Or
(IsNull(Forms!ALLFORM!HyperlinkSubform.Form!Hyperlink1)) Then
CheckFieldIN = False
Else
CheckFieldIN = True
End If
End Function
/////////////////////////
Function CheckFieldOUT() As Boolean
If Me.AddNewRecOUT.Enabled = True And IsNull(Me.RegisterNumber) Or
IsNull(Me.DateSent) Or IsNull(Me.SentTo) Or IsNull(Me.DeptCode) Or
IsNull(Me.Designation) Or IsNull(Me.Subject) Or IsNull(Me.CompanyName) Or
(IsNull(Forms!ALLFORM!HyperlinkSubform.Form!Hyperlink1)) Then
CheckFieldOUT = False
Else
CheckFieldOUT = True
End If
End Function
 
S

Sue Wilkes

Hi Wayne, maybe I'm confusing the issue to clarify I need a command button on
the main form only to enable when the field on the subform has been completed
(assuming it possible) many thanks Sue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top