[AccessD] Don't Want form to open

Arthur Fuller artful at rogers.com
Thu Jan 30 08:25:00 CST 2003


Your test fails to take Me![UserID] into consideration, which means that DCount() will always return non-zero as long as there are rows in said table. You need to carry the test down to the Dcount() line.

hth,
Arthur
  ----- Original Message ----- 
  From: Hollis,Virginia 
  To: 'accessd at databaseadvisors.com' 
  Sent: Thursday, January 30, 2003 8:55 AM
  Subject: [AccessD] Don't Want form to open


  I have been off the list for awhile - you sure have gotten fancy with subscribing the last few months!!

  ***********
  Problem:

  I have a form that users select their name from a combobox, it opens a main form that allows them to edit only active requests. I am having problems with the main form opening even if they do not have any active requests (they are closed). If they do not have any active requests, the message box "No Open EFRs" should display, but it doesn't, the frmSystemFailure opens & I receive an error, can't go to specified record (on the main form OnOpen, I have it set focus to a certain field).

  How can I prevent the frmSystemFailure from opening & display the message? UserID is the name of the combobox.

   'Status is Pending, In Progress, or In Review, and User ID = Engineer ID
      stDocName = "frmSystemFailure"
      stLinkCriteria = "[EngineerID]=" & Me![UserID] & " AND [StatusID] = 1" & _
      "Or [EngineerID]=" & Me![UserID] & " AND [StatusID] = 2" & _
      "Or [EngineerID]=" & Me![UserID] & " AND [StatusID] = 4"
             
      ' Check whether the user has any EFRs open. If they do, open the
      ' form with a filter.
  On Error Resume Next
      If DCount("EngineerID", "tblEngineer", stLinkCriteria) Then
          DoCmd.OpenForm stDocName, , , stLinkCriteria
      Else
          'Display Message "No open EFRs"
          MsgBox "No open EFRs for " & Forms![frmUpdateEFRs]![UserID].Column(1)
      End If

      ' Close the dialog box.
      DoCmd.Close acForm, "frmUpdateEFRs"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030130/f06860f1/attachment-0002.html>


More information about the AccessD mailing list