Re: Connecting to a SQL Server 2005 using VBA and ADO
- From: "Albert D. Kallal" <PleaseNOOOsPAMmkallal@xxxxxxx>
- Date: Tue, 12 Jun 2007 15:41:48 -0600
Any reason you don't leave the code as you have?
The code example you have should work just fine....
dao should work just fine....
if that table is linked, then your code should work as is.
I would not use find first in this case, but perhaps you have reason for
doing so.....
I would have used:
dim rst as dao.RecordSet
set rst = currentdb.openrecordset("select * from contacts where contactid =
12345")
if rst.RecordCount > 0 then
'....do whatever....
end if
the above will work if you using linked tables to a back end mdb, or if your
tables are linked to sql server...the code does not need to be changed in
the above example when using sql server, or a plan Jane un-split database,
or a split database.
The above code will work fine for all 3 cases..and should not need to be
modified.....
I would not use findfirst even when not using sql server unless the data set
was small, and you had to repeat use findfirst a number of times. It is
generally better to just fetch the one record as a above then doing a table
scan with findfirst...
Also, I used dao.RecordSet, but if you don't have a reference to ado, then
your use of "RecordSet" should work just fine also...
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@xxxxxxx
.
- Follow-Ups:
- Prev by Date: Re: Weird Listbox Criteria Error
- Next by Date: Re: Tab Control
- Previous by thread: Re: Does anyone use AcCmdSend?
- Next by thread: Re: Connecting to a SQL Server 2005 using VBA and ADO
- Index(es):
Relevant Pages
|