473,382 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

open form with where conditioning

Good Morning

Have the following code and is all working but I need to add an additional section to the where clause but cannot get it to work I need to add to both dcounts [log Number] = me![Log Number] any ideas

Expand|Select|Wrap|Line Numbers
  1. Private Sub Submit_Click()
  2. If IsNull(Me.Serial_Number) = True Or IsNull(Me.Log_Number) Or IsNull(Me.Type_of_Incident) = True Then
  3. MsgBox "Feilds cannot be Left Blank"
  4.  
  5. Exit Sub
  6. End If
  7.  
  8.  
  9. If DCount("*", Me![type of incident], "[serial number] = """ & Me![serial Number] & """") = 1 Then GoTo openform
  10. If DCount("*", Me![type of incident], "[serial Number] = """ & Me![serial Number] & """") = 0 Then GoTo Error1
  11.  
  12. Error1:
  13. MsgBox "Incident does not exist Please check you inputted Data and try again", , "Report Does Not Exist"
  14. Exit Sub
  15.  
  16. openform:
  17. DoCmd.openform Me.Type_of_Incident, , , "[Serial Number]='" & Me![serial Number] & "' and [Log Number]='" & Me![log Number] & "'"
  18.  
  19. DoCmd.Close acForm, "continue report", acSaveNo
  20. DoCmd.Close acForm, "Selection", acSaveNo
  21.  
  22. End Sub
Thank you
Jun 14 '13 #1
1 993
Seth Schrock
2,965 Expert 2GB
First, there is no reason to run the DCount twice. Domain functions (any of the functions that start with D, ie. DCount, DLookup, DSum, etc.) all use lots of system resources. Instead, use the Select Case to test the value.

As for the adding of the Log Number to the DCount criteria, just copy what you have in the DoCmd.OpenForm criteria as it looks correct assuming text fields and not number fields.
Jun 14 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Filips Benoit | last post by:
A particular form - always the same - sometimes becomes corrupt after saving. Error msg = The expression On Open you entered as the event property settings produced the following error: A...
3
by: BLUE WATER | last post by:
Hi, I have managed to simplify my problem but can't seem to get this to work. I want to open up a form from a click event of another form, but not only open the form when the button is pressed...
2
by: allyn44 | last post by:
Hello, I have built a serch form for users to edit records. I only want them to pull up the record they need, and I want to check for nulls. There should not be dupes becasue the underlying...
3
by: kev | last post by:
Hi folks, I have a form for registration (frmRegistration) whereby i have two buttons. One is Save which saves record using the OnClick property. I used wizard to create the save button. The...
14
by: keri | last post by:
Hi, Simple version of the question..... How do I use the where clause of the open form command to show an account with a matching ID to be displayed when the form is opened? Eg. I select a...
12
by: djmauro | last post by:
as title says. I cant find a way to do this. if i use form1.show and click on a button. it opens that form, but as soon as i click again it just reopens it and closes previously opened form. So is...
10
by: Beatrice | last post by:
I need to open a form selecting all data from a previous form i.e: Form 1) combo box 1 named "cboYearSelect" displayed as "Year" based on qry QryYearList ( only one field "Year") ...
5
by: billa856 | last post by:
Hi, My project is in MS Access 2002. In that I want to open one form multiple times. I put one button on my main form. Now whenever I click on that button than form will be open. Now when I...
10
reginaldmerritt
by: reginaldmerritt | last post by:
I'm trying to open a form where the value of a field has a date closest to today but not beyond todays date. I guess i need some sort of MAX function in a where statment maybe???? Any ideas how...
3
by: birdbite | last post by:
Hello, this is my first post. Thanks for reading. I am trying to open a form on a Click event where the records displayed are what the user has selected on several form combo boxes. Some of the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.