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

Sql Statement Syntax

Access 2000 Frt End connected to SQL 2000

I am trying to ck for the existance of a record in another table with
the same ClientID and Date.
I am ck'ing for a record in tblMedInfo that has the same "ClientID"
(Long Interger) and "DateEntered" (Short Date mm/dd/yyyy) as the form
"frmClients.ClientID" and "frmClients.LastUpdate"

Yet again, it's the sql statement that has me stumped.

Dim dbs As Database
Dim rst As Recordset
Dim qry As String
Dim vDate As Date

vDate = Me.LastUpdate

Set dbs = CurrentDb()
qry = "Select * from tblMedInfo where tblMedInfo.[ClientID] = " &
Forms!frmClients.[ClientID] & "" And (((tblMedInfo.DateEntered) = " & #
vDate # & "))

Set rst = dbs.OpenRecordset(qry, dbOpenDynaset)
If rst.RecordCount 0 Then
MsgBox "Record Exsist"
Else
MsgBox "Will Open And Add Record"
End If

Any Suggestions Appreciated
Dale

Oct 11 '06 #1
4 1265
pks
Dale,

Are you receiving an error message, or is it just not bringing up the
record? WIthout being able to test your code right now, I can tell you
that the recordcount isn't populated until you do a rst.MoveLast.

Another option is to change your statement to
If rst.eof = false then
...
Else

Oct 11 '06 #2
pks
Dale,

Are you receiving an error message, or is it just not acknowledging the
record? Without being able to test your code right now, I can tell you
that the recordcount isn't populated until you do a rst.MoveLast.

Another option is to use EOF (end of file) in your statement, such as:
If rst.eof = false then
...
Else
...
End If

pks

Oct 11 '06 #3
Bri


pks wrote:
Dale,

Are you receiving an error message, or is it just not acknowledging the
record? Without being able to test your code right now, I can tell you
that the recordcount isn't populated until you do a rst.MoveLast.

Another option is to use EOF (end of file) in your statement, such as:
If rst.eof = false then
...
Else
...
End If

pks
If there are records then RecordCount will be 1 (one) prior to a Move,
so his IF statement will work if the query is working as he is just
testing that it is greater than zero.

--
Bri

Oct 11 '06 #4
Bri

Dale wrote:
Access 2000 Frt End connected to SQL 2000

I am trying to ck for the existance of a record in another table with
the same ClientID and Date.
I am ck'ing for a record in tblMedInfo that has the same "ClientID"
(Long Interger) and "DateEntered" (Short Date mm/dd/yyyy) as the form
"frmClients.ClientID" and "frmClients.LastUpdate"

Yet again, it's the sql statement that has me stumped.

Dim dbs As Database
Dim rst As Recordset
Dim qry As String
Dim vDate As Date

vDate = Me.LastUpdate

Set dbs = CurrentDb()
qry = "Select * from tblMedInfo where tblMedInfo.[ClientID] = " &
Forms!frmClients.[ClientID] & "" And (((tblMedInfo.DateEntered) = " & #
vDate # & "))

Set rst = dbs.OpenRecordset(qry, dbOpenDynaset)
If rst.RecordCount 0 Then
MsgBox "Record Exsist"
Else
MsgBox "Will Open And Add Record"
End If

Any Suggestions Appreciated
Dale
You have an extra " and some missing ones. The # symbols need to be in
the quoted part. It is a good idea to declare the table that the * is
referring too (for your benifit and it is required if you want to view
this in the Query Designer). Also, to avoid Date confusions it is a good
idea to format it into an unambiguous form before inserting it into a
string. I am assuming that ClientID is a number and not text. I cleaned
up your statement below:

qry = "Select tblMedInfo.* from tblMedInfo " & _
"Where tblMedInfo.ClientID = " Forms!frmClients.ClientID & _
" And tblMedInfo.DateEntered = #" & Format(vDate,"dd-mmm-yy") & "#"

Give that a try and if you still have problems come back with more info.

--
Bri

Oct 11 '06 #5

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

Similar topics

47
by: Andrey Tatarinov | last post by:
Hi. It would be great to be able to reverse usage/definition parts in haskell-way with "where" keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable...
6
by: HeadScratcher | last post by:
I am trying to speed up my update statements by removing inner select statements. Example: update orders set shipname = (select contactName from customers where customerid = orders.customerID)...
7
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double...
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
28
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
6
by: Heiko Wundram | last post by:
Hi all! The following PEP tries to make the case for a slight unification of for statement and list comprehension syntax. Comments appreciated, including on the sample implementation. ===...
23
by: florian.loitsch | last post by:
According to the spec Section 14 the production SourceElements:SourceElements SourceElement is evaluated as follows: 1. Evaluate SourceElements. 2. If Result(1) is an abrupt completion, return...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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: 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...

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.