473,396 Members | 2,106 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,396 software developers and data experts.

Use queries within IF...THEN

Hi all,
I have created a nice working database for keeping track of helpdesk calls,
corrective actions etc.

To determine a certain status (for example what calls are ready for test,
after all actions have been finished) I created queries. Because these
statusses are depending on more than one parameter, I would like to
automate the status setting.

So my idea is to put IF...THEN logic underneath AfterUpdate events of all
fields that can influence a certain status.

For example, one call could have many actions. An action could be critical
(Y/N) for retest (meaning it should always be finished before the call is
retested) and an action could be Finished (Y/N). When I change these two
boolean fields, I would like to trigger some IF...THEN logic that uses my
query. Something like

Private Sub Finished_AfterUpdate()
If Me.Call_ID NOT EXIST IN qryReadyForRetest Then

etc.

End Sub

This is not working.
How do I do this?
In the end I would like a status field in tblCall be updated after a field
in tblAction is updated and it meets my criteria.

Hope someone understands and can help.

Thanks,

Koen
Nov 12 '05 #1
3 1502
How about this?

Private Sub Finished_AfterUpdate()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim sSQL As String

Set dbs = Currentdb()
sSQL = "SELECT Count(*) As MyCount FROM qryReadyForRetest " & _
" WHERE Call_ID = " & Me.Call_ID
Set rst = dbs.OpenRecordset(sSQL, dbOpenSnapshot)
If rst!MyCount = 0 Then
' do stuff here
End If
Set rst = Nothing
Set dbs = Nothing
End Sub

--
Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"Koen" <no@spam.nl> wrote in message
news:Xn*********************@194.109.133.20...
Hi all,
I have created a nice working database for keeping track of helpdesk calls, corrective actions etc.

To determine a certain status (for example what calls are ready for test,
after all actions have been finished) I created queries. Because these
statusses are depending on more than one parameter, I would like to
automate the status setting.

So my idea is to put IF...THEN logic underneath AfterUpdate events of all
fields that can influence a certain status.

For example, one call could have many actions. An action could be critical
(Y/N) for retest (meaning it should always be finished before the call is
retested) and an action could be Finished (Y/N). When I change these two
boolean fields, I would like to trigger some IF...THEN logic that uses my
query. Something like

Private Sub Finished_AfterUpdate()
If Me.Call_ID NOT EXIST IN qryReadyForRetest Then

etc.

End Sub

This is not working.
How do I do this?
In the end I would like a status field in tblCall be updated after a field
in tblAction is updated and it meets my criteria.

Hope someone understands and can help.

Thanks,

Koen

Nov 12 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You have to return the results of a query in a Recordset. Your
example indicates that the query "qryReadyForRetest" should be the
data source in another query, and assumes that qryReadyForRetest
returns a single column "Call_ID."

' Sets up Call_ID as a numeric data type
' If it is an alphanumeric data type use
' Call_ID = '" & Me.Call_ID & "'"

dim strSQL As String
strSQL = "SELECT Call_ID FROM qryReadyForRetest " & _
"WHERE Call_ID=" & Me.Call_ID

dim db as dao.database
dim rs as dao.recordset
set db = currentdb
set rs = db.openrecordset(strsql)

If not rs.eof then ' the Call_ID exists
... etc. ...
HTH,

MGFoster:::mgf
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP9Dju4echKqOuFEgEQKjVgCfckyrrBGG/InOM6hwiDdxGZLsnS4AoKC9
2tNyXoyGI6IbFnZCA2IgZXij
=9+lW
-----END PGP SIGNATURE-----

Koen wrote:
Hi all,
I have created a nice working database for keeping track of helpdesk calls,
corrective actions etc.

To determine a certain status (for example what calls are ready for test,
after all actions have been finished) I created queries. Because these
statusses are depending on more than one parameter, I would like to
automate the status setting.

So my idea is to put IF...THEN logic underneath AfterUpdate events of all
fields that can influence a certain status.

For example, one call could have many actions. An action could be critical
(Y/N) for retest (meaning it should always be finished before the call is
retested) and an action could be Finished (Y/N). When I change these two
boolean fields, I would like to trigger some IF...THEN logic that uses my
query. Something like

Private Sub Finished_AfterUpdate()
If Me.Call_ID NOT EXIST IN qryReadyForRetest Then

etc.

End Sub

This is not working.
How do I do this?
In the end I would like a status field in tblCall be updated after a field
in tblAction is updated and it meets my criteria.

Hope someone understands and can help.

Thanks,

Koen

Nov 12 '05 #3
Koen,
you need to open a recordset based on your query, and then you can do
something with it. You'd have to do something like pass the CallID
into the query as a parameter and then open a recordset based on that.
Then you could do a recordcount or whatever and then respond to
that...

If rst.RecordCount=0 Then
'Do one thing
Else
'Do another
End If

Also, you cannot use EXISTS outside of a subquery. (Well, as far as I
know anyway... I could not get it to work the one time I tried it.)
Nov 12 '05 #4

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

Similar topics

1
by: Roger Green | last post by:
I have inherited a complex database that has many dozens of queries that derive data from a people table. I now need to be able to run these queries (from within a significant number of forms)...
9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
5
by: Martin Lacoste | last post by:
There's likely not a simple answer for this, I know, but, I thought I'd try anyways... Background.. I've been racking my brain with some queries that I thought were straightforward, but have...
2
by: Tim Pollard | last post by:
Hi I'm hoping someone can help me with an access problem I just can't get my head around. I normally use access as a back end for asp pages, just to hold data in tables, so queries within access...
0
by: MHenry | last post by:
Hi, I know virtually nothing about creating Macros in Access. I would appreciate some help in creating a Macro or Macros that automatically run(s) 14 Queries (three Make Table Queries, and 11...
44
by: Greg Strong | last post by:
Hello All, Is it better to create a query in DAO where a report has 4 sub-reports each of whose record source is a query created at runtime and everything is in 1 MDB file? From what I've...
1
by: loosecannon_1 | last post by:
Hello everyone, I am hoping someone can help me with this problem. I will say up front that I am not a SQL Server DBA, I am a developer. I have an application that sends about 25 simultaneous...
14
by: google | last post by:
I am creating a new database for use within our company, that I'd like to make reasonably secure (short of a true server based solution). The back-end of a non-server based database seems to be...
8
by: Sheldon | last post by:
I just received a 2nd (configured as a dual) monitor but, for Access only, I can't seem to figure out, if it's possible, to view, say, Table1 on one monitor and Table2 on the other monitor. If I...
5
by: DonnaL | last post by:
I'm using Access 2000, but this question likely pertains to any version of Access. Simply put, is there a programmatic way of inserting a new Query in whatever master system table stores these...
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: 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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.