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!

reference a forms control from a Public function 1

Status
Not open for further replies.

pandapark

Technical User
Jan 29, 2003
92
GB
Hi

I have a generic Public Function called Validator as below. It doesn't like the Forms!Screen.ActiveForm.Name!Frame1001 - how can I get round this please ?
also can you call other functions from within a function as I've tried below ?

regards
gareth

Public Function PAIS_Page1() As Boolean

If (IsNull(Forms!Screen.ActiveForm.Name!Frame1001) Or Forms!Screen.ActiveForm.Name!Frame1001 = 0) Then
Forms!Screen.ActiveForm.Name!Frame1001.tag = True
Else
Forms!Screen.ActiveForm.Name!Frame1001.tag = False
End If

If IsNull(Forms!Screen.ActiveForm.Name!directorate) Or IsNull(Forms!Screen.ActiveForm.Name!action_desc) _
Or IsNull(Forms!Screen.ActiveForm.Name!employee) Or Forms!Screen.ActiveForm.Name!employee = "" _
Or Forms!Screen.ActiveForm.Name!directorate = "" Or Forms!Screen.ActiveForm.Name!action_desc = "" _
Or IsNull(Forms!Screen.ActiveForm.Name!new_service) Or Forms!Screen.ActiveForm.Name!new_service = "" _
Or IsNull(Forms!Screen.ActiveForm.Name!interview_date) Or (IsNull(Forms!Screen.ActiveForm.Name!Frame1001) Or Forms!Screen.ActiveForm.Name!Frame1001 = 0) Then
Msgbox ("You have not completed the required fields." & Chr(10) & _
"You must enter information in the following fields:" & Chr(10) & Chr(10) & _
"Directorate" & Chr(10) & _
"Description" & Chr(10) & _
"Service" & Chr(10) & _
"Employee" & Chr(10) & _
"Interview Date" & Chr(10) & _
"Team or Individual")

Call ColorValidator1
Call SiteMap_1

CheckFields = False
Else
CheckFields = True
Call SiteMap_0
End If

end function
 
Give this a shot:

Code:
Public Function PAIS_Page1() As Boolean
[red]Dim frm as Form[/red]

    [red]Set frm = Forms("YourFormName")[/red]

    If (IsNull(frm!Frame1001) Or frm!Frame1001 = 0) Then
      frm!Frame1001.tag = True
    Else
      frm!Frame1001.tag = False
    End If
...

Shane
 
Try playing around with this:

Code:
Function getActiveForm()
 Dim strFormname As Variant ' so it will handle nulls when no form is open
  
 'set strFormname = currently active form name
 strFormname = Screen.ActiveForm.Name
 
 If IsNull(strFormname) Then
     MsgBox "No Form found"
 Else
     MsgBox "Active form:  " & Nz(strFormname, "")
 End If

End Function

Place a button on a form and set it's click event to getActiveForm


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top