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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form focus problem

Status
Not open for further replies.

gloudo

Programmer
Feb 3, 2002
34
0
0
NL
Hi all,

I Have a problem keeping the focus on a form.

When my database generates an error I have an Error handler wich opens a form showing the error details.

This all works fine, but because the form loads from the line below it takes the focus back after runnung the code and hides the error form behind the form wich generated the error.

Code:
Exit_Form_Open:
6     Exit Sub

Err_Form_Open:
7     FoutMelding Err.Source, "Form_Open", Erl, Err.Number, Err.Description, Me.Name
8     Resume Exit_Form_Open

Code:
Function FoutMelding(stSource As String, stProcedure As String, intRegel As Integer, dblFoutnummer As Double, stFoutmelding As String, Optional stForm As String)
1     On Error GoTo Err_FoutMelding

2     DoCmd.OpenForm "frmFoutmelding", , , , , , stForm

3     Forms!frmFoutmelding!txtFoutmelding = _
      "Foutnummer: " & dblFoutnummer & vbCrLf _
          & "Foutomschrijving" & vbCrLf & stFoutmelding & vbCrLf _
          & "--------------------------------------------" & vbCrLf _
          & "DataBase : " & stSource & vbCrLf _
          & "Formulier: " & stForm & vbCrLf _
          & "Procedure: " & stProcedure & vbCrLf _
          & "Regel:     " & intRegel

Exit_FoutMelding:
4     Exit Function
          
Err_FoutMelding:
5     MsgBox "Foutmelding: " & Err.Description, vbCritical, "Fout: " & Err.Number
6     Resume Exit_FoutMelding
          
End Function
This is the function wich creates the error text and opens the errormessage form (frmFoutmelding)

I've tried to hide the form from the error form but this doesn't work either.

Anyone have an idea how to solve this?
 
I'd try this:
Code:
DoCmd.OpenForm "frmFoutmelding", , , , , [!]acDialog[/!], stForm

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks DHV this helped me partly, but You sent me in the right direction, wich resulted in the solution.

By adding acdialog in the docmd.openform line , the text generated in the function didn't came through. But by putting it as the openargs it's working like a charm now.

Thanks for your quick reaction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top