473,387 Members | 1,532 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,387 software developers and data experts.

Alert about existing record

Hi,

As a relative Newbie, I'd appreciate a little assistance with an A2003
DB I'm trying to enhance.

This DB handles reports made by security staff on a shift by shift
basis based on two shifts per day. The two relevant fields are called
Datum and Shift.

I want to trigger an alert whenever the user tries to create a new
report when a report for that Datum / Shift combination already
exists. Ideally the alert would be triggered in the After Update Event
in the Shift. If the alert wasn't triggered then another form would
open so allowing the user to create a new report.

I have made a query called qryAlertExisting which produces distinct
Datum/Shift results and I wanted to use this with a bit of code I've
taken from another of my DB's which triggers an alert but is based on
searching one field only. What I want now is to modify this code to
consider two fields (Datum & Shift) and to flag up if the proposed new
combination already exists.

The code is :-
If DCount("Datum","QryAlertExisting")<1 Then
DoCmd.OpenForm "FrmAddNewReport"
Else
MsgBox "A report already exists for that Shift on that Date""
End if
Many thanks,

Yvonne
Jun 27 '08 #1
4 1140
On May 8, 3:20*am, senditont...@gmail.com wrote:
Hi,

As a relative Newbie, I'd appreciate a little assistance with an A2003
DB I'm trying to enhance.

This DB handles reports made by security staff on a shift by shift
basis based on two shifts per day. The two relevant fields are called
Datum and Shift.

I want to trigger an alert whenever the user tries to create a new
report when a report for that Datum / Shift combination already
exists. Ideally the alert would be triggered in the After Update Event
in the Shift. If the alert wasn't triggered then another form would
open so allowing the user to create a new report.

I have made a query called qryAlertExisting which produces distinct
Datum/Shift results and I wanted to use this with a bit of code I've
taken from another of my DB's which triggers an alert but is based on
searching one field only. What I want now is to modify this code to
consider two fields (Datum & Shift) and to flag up if the proposed new
combination already exists.

The code is :-
If DCount("Datum","QryAlertExisting")<1 Then
* * DoCmd.OpenForm "FrmAddNewReport"
Else
* * MsgBox "A report already exists for that Shift on that Date""
End if

Many thanks,

Yvonne
use the 'where' clause in dcount, assuming the field on your form for
shift is called 'shift'

If DCount("Datum","QryAlertExisting", "shift = " & shift)<1 Then
DoCmd.OpenForm "FrmAddNewReport"
Else
MsgBox "A report already exists for that Shift on that Date""
End if
Jun 27 '08 #2
Hi Roger,

As I'm still very much on the learning curve, I'm not too sure where I
put the word 'Where' in the code. I used the code you suggested
without a 'Where' and it came back with the message;_

Syntax error (missing operator) in query expression 'Shift = Late'

Also, would it be better if the text boxes were renamed txtDatum and
TxtShift as opposed to Datum and Shift after the fields they
represent?

Much appreciated.

Yvonne

Jun 27 '08 #3
On May 8, 5:16*am, senditont...@gmail.com wrote:
Hi Roger,

As I'm still very much on the learning curve, I'm not too sure where I
put the word 'Where' in the code. I used the code you suggested
without a 'Where' and it came back with the message;_

Syntax error (missing operator) in query expression 'Shift = Late'

Also, would it be better if the text boxes were renamed txtDatum and
TxtShift as opposed to Datum and Shift after the fields they
represent?

Much appreciated.

Yvonne
if you put the cursor over the word 'dcount' and hit f1 for help,
you'll see that this function takes up to three parameters and the
third is a 'where' expression

since the shift field is textual it needs to be surrounded by single
quotes, your code should look like

If DCount("Datum","QryAlertExisting", "shift = 'Late'")<1 Then
DoCmd.OpenForm "FrmAddNewReport"
Else
MsgBox "A report already exists for that Shift on that Date""
End if
that is double-quote shift equal single-quote late single-quote double-
quote

as to renaming text boxes, it's a matter of preference.. I like the
text box name to match the field name so that I don't need to do
mental translation when working with vba
Jun 27 '08 #4
Roger,

All sorted now, many thanks.

Yvonne

Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tom Cusick | last post by:
We have a Job Shop database. When I get an order in I put all the line item information into the database. Some orders have multiple lines and most of the information is the same. (eg. Customer...
2
by: Seth | last post by:
I have a query with field names and . When I access any given record in form "test", I want the user to be alerted if there is more than one record with the same first name and last name. This...
4
by: sonu | last post by:
How can we use alert and confirm method in asp.net application. i am working with application where i want to use confirm box before going for any operation. and same for alert box Sonu
2
by: Mark Perona | last post by:
I created an ASP.net form with an editable datagrid on it. I can create new records, and update and delete existing records. The problem I have is that I want a field in the grid to be editible...
3
by: musclehead | last post by:
Hi everyone, I have, what I hope, will be a simple question. I have a basic JS function to pop-up a confirm delete dialog box when deleting a record from a DB: function confirmDelete() { var...
6
by: jcf378 | last post by:
hello-- i am having trouble figuring out how to export individual records from an Access 2002 Form into a pre-existing Excel spreadsheet, such that the exported record is merely appended to the...
14
nitindel
by: nitindel | last post by:
Hi All, I am working on ASP , VBScript and Javascript. I am making a grid in ASP VBScript..and eneter checkboxes in one column...... The problem is that if there is one record in the grid it is...
4
by: hon123456 | last post by:
Dear all, I have the following code which add a new record to database, after the record has been added. I want to prompt a message "Hello". But the following script does not promt....
2
by: Jonathan N. Little | last post by:
As part of a JavaScript precheck form validation I noticed a problem with trying to return focus to the field with an error. I have setup a demo page. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: 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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.