Checking if a form is active

  • Thread starter Thread starter Guest
  • Start date Start date
Thank you,
I am trying to use it, but i get a 'type mismatch' error.
I want to check if a form called 'receiptsF' is active, so i wrote:
If (screen.ActiveForm([forms]![receiptsF])) Then ...

I tried looking in Qbuilt, but didn't find an answer there.
Does anybody know the exact syntax?

Thanks
 
Thank you,
I am trying to use it, but i get a 'type mismatch' error.
I want to check if a form called 'receiptsF' is active, so i wrote:
If (screen.ActiveForm([forms]![receiptsF])) Then ...

hightlight ActiveForm and press F1 then you will now what this Object
is giving you, like a Name to use like:

If (screen.ActiveForm.Name="receiptsF") Then

If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW
 
Try the following syntax and make sure that error handling is included in
your procedure (otherwise, an unfriendly, confusing Access error will be
displayed to the user):

Private Sub ActiveFormBtn_Click()

On Error GoTo ErrHandler

If (Screen.ActiveForm.Name = Forms("receiptsF").Name) Then
MsgBox "It's the active form.", vbInformation + vbOKOnly, _
" Found Active Form"
Else
MsgBox "It's not the active form.", vbInformation + vbOKOnly, _
"Form Open, But Not Active"
End If

Exit Sub

ErrHandler:

If (Err.Number = 2450) Then
MsgBox "This form isn't open.", vbInformation + vbOKOnly, _
" Form Not Found"
Else
MsgBox "Error in ActiveFormBtn_Click( )" & vbCrLf & "in " & _
Me.Name & " form." & vbCrLf & vbCrLf & "Error #" & _
Err.Number & vbCrLf & Err.Description
Err.Clear
End If

End Sub


HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)


dshemesh said:
Thank you,
I am trying to use it, but i get a 'type mismatch' error.
I want to check if a form called 'receiptsF' is active, so i wrote:
If (screen.ActiveForm([forms]![receiptsF])) Then ...

I tried looking in Qbuilt, but didn't find an answer there.
Does anybody know the exact syntax?

Thanks

'69 Camaro said:
Hi.

Use Screen.ActiveForm.Name to determine the name of the active form.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 
Back
Top