Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL problems in VBA!!!! please help!

Status
Not open for further replies.

BigFizil

MIS
Mar 9, 2003
23
US
here is my code and it works fine as is:

Set cn = CurrentProject.Connection
Set rst = New ADODB.Recordset

With rst
.PageSize = 8
.ActiveConnection = cn
.Source = "SELECT * From Development, developmentpictures"
.LockType = adLockOptimistic
.CursorType = adOpenStatic
.Open

BUT!!!

this returns too much information and when I attempt to alter the SQL query such as below ...I get an error with ".OPEN" highlighted in VBA

Set cn = CurrentProject.Connection
Set rst = New ADODB.Recordset

With rst
.PageSize = 8
.ActiveConnection = cn
.Source = "SELECT * From Development, developmentpictures WHERE Development.Kinder Number = developmentpictures.Kin Num"
.LockType = adLockOptimistic
.CursorType = adOpenStatic
.Open


PLEASE HELP!!!!!!

 
.Source = "SELECT * From Development, developmentpictures WHERE Development.Kinder Number = developmentpictures.Kin Num"

is probaby the cause of the error. I think that you need to say "select development.* , developmentPictures.* FROM Development, developmentpictures WHERE Development.Kinder Number = developmentpictures.Kin Num"


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
I am still getting an error and it has something to do with ".open"

???
 
when you try to .open a faulty query, you will get the query where you open, not where you write the query...

simplify and see what you get...

.Source = "SELECT * From Development"


should work fine.... You may need to work on the join...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top