Problem With IsFormLoaded Do Loop Code

D

Doc

The code is meant to open a form, get input, hide the form, take the input
and apply it to the first form. Basically, if the user selects 'Other', I
want to know what the Name and Category of the 'Other' is. When the form
opens, if the user only uses the keyboard, everything works fine. However,
if the user actually clicks the combo box to select an option, it wont let
them select any of the options. Wierd.

3 chunks of code; 'CurSysRequest()' is the code that runs the main form,
CurSysRequestOther() is on a field as 'After Update', and the code that
checks the IsFormLoaded function. The IsFormVisible is exaclty the same,
only it checks if frm.Visible = true.

One other anomoly worth mentioning, if the user right clicks to try and
select an option in the pop up window, they get an error message that states
that the BeforeUpdate or Validation Rule is preventing the database from
saving the field, and then the user can select an option, but by that point
the code has stopped functioning.

Thanks in advance!!

Function CurSysRequest()
On Error GoTo ErrHand
Dim frm As Form, IDSystem As Integer, IDPeople As Integer
Dim Category As String, FuncName As String, Found As String
Dim IDPriority As Integer, Desc As String, eCode As String

If IsFormLoaded("frmHiddenUser") = False Then
MessageForm "A critical compenent is missing, and the database must
exit!"
Ext
End If

IDPeople = Forms!frmHiddenUser!UserName

DoCmd.OpenForm "frmCurSys"
If IsFormLoaded("frmCurSys") = False Then Exit Function
Set frm = Forms!frmCurSys

Do
If IsFormLoaded("frmCurSys") = False Then Exit Do
If IsFormVisible("frmCurSys") = False Then Exit Do
DoEvents
Loop

If IsFormLoaded("frmCurSys") = False Then Exit Function
IDSystem = frm!System
Category = frm!Category
FuncName = frm!FuncName
Found = frm!Found
IDPriority = frm!Priority
Desc = frm!description
If IsNull(frm!eCode) Then
Desc = frm!description
Else
eCode = frm!eCode
Desc = "Error Code: " & eCode & "; " & frm!description
End If



MsgBox Desc

If IsFormLoaded("frmCurSys") Then DoCmd.Close acForm, frm.Name
Exit Function

ErrHand:
MsgBox Err.description
ErrorLog "MDSSFunc", "CurSysRequest", "eMf-202", Screen.ActiveForm.Name,
Err.Number, Err.description
End Function


Function CurSysRequestOther()
On Error GoTo ErrHand
Dim frm As Form, str As String

If IsFormLoaded("frmCurSys") = False Then Exit Function
Set frm = Forms!frmCurSys

If frm!System = 4 Then
DoCmd.OpenForm "frmCurSysOther"
If IsFormLoaded("frmCurSysOther") = False Then Exit Function

Set frm = Forms!frmCurSysOther

frm.Modal = True

Do
If IsFormLoaded("frmCurSysOther") = False Then Exit Do
If IsFormVisible("frmCurSysOther") = False Then Exit Do
DoEvents
Loop

Exit Function

If IsFormLoaded("frmCurSysOther") = False Then
If IsFormLoaded("frmCurSys") = True Then DoCmd.Close acForm,
"frmCurSys"
Exit Function
End If

str = "Name: "
str = str & frm!FuncName
str = str & "; Category: "
str = str & frm!SysType

If IsFormLoaded("frmCurSysOther") Then DoCmd.Close acForm,
"frmCurSysOther"

MsgBox str


End If

frm!Category.SetFocus

Exit Function

ErrHand:
MsgBox Err.description
'ErrorLog "MDSSFunc", "CurSysRequestOther", "eMf-204",
Screen.ActiveForm.Name, Err.Number, Err.description
End Function


Function IsFormLoaded(frmname As String) As Boolean
On Error GoTo ErrHand
Dim frm As Form
IsFormLoaded = False
For Each frm In Forms
If frm.Name = frmname Then
IsFormLoaded = True
Exit For
End If
Next frm
Exit Function
ErrHand:
ErrorLog "MFunc", "IsFormLoaded", "eFn-121", Screen.ActiveForm.Name,
Err.Number, Err.description
End Function
 
D

Doc

As it turns out, I just had to move the focus to the next field before
opening the secondary form. . .
 

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