Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / May 2008

Tip: Looking for answers? Try searching our database.

Problem With IsFormLoaded Do Loop Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Doc - 19 May 2008 21:10 GMT
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
Doc - 19 May 2008 21:48 GMT
As it turns out, I just had to move the focus to the next field before
opening the secondary form. . .

> 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
[quoted text clipped - 134 lines]
> Err.Number, Err.description
> End Function
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.