Hollis,Virginia
HollisVJ at pgdp.usec.com
Thu Jan 30 08:50:01 CST 2003
It seems to have something to do with the status criteria. If I take out the, AND [StatusID] = 1.... and just use stLinkCriteria = "[EngineerID]=" & Me![UserID] then it works. Do I have the stLinkCriteria where it checks the status code wrong? Virginia -----Original Message----- From: Mike and Doris Manning [mailto:mikedorism at ntelos.net] Sent: Thursday, January 30, 2003 8:36 AM To: accessd at databaseadvisors.com Subject: RE: [AccessD] Don't Want form to open Me![UserID] is taken into account. Virginia builds it into the stLinkCriteria variable. The real problem is that DCount returns a count of records matching stLinkCriteria. She was always getting the error message because unless you explicitly tell an IF..THEN statement how to evaluate the results then it assumes you are working with a boolean and in this particular case, the value was not and never would = TRUE. Doris Manning Database Administrator Hargrove Inc. www.hargroveinc.com -----Original Message----- From: accessd-admin at databaseadvisors.com [mailto:accessd-admin at databaseadvisors.com] On Behalf Of Arthur Fuller Sent: Thursday, January 30, 2003 09:22 AM To: accessd at databaseadvisors.com Subject: Re: [AccessD] Don't Want form to open 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 <mailto:HollisVJ at pgdp.usec.com> To: 'accessd at databaseadvisors.com' <mailto:'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/62f0ebea/attachment-0002.html>