Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 7th, 2007, 04:18 AM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default Runtime error '3296'

Hi All,

I am getting this error
Runtime error '3296'

Me.ExportSPriceToExcel_subform.Form.Recordsource = "SELECT Products.PID, SPrice.PID, Products.SID, Suppliers.[Name], Products.[Description], Products.ProductType, SPrice.MinQuan, SPrice.Currency, SPrice.Price, SPrice.Type, SPrice.SDate FROM (Suppliers INNER JOIN Products ON Suppliers.SID ='" & SupplierID & "' and Products.ProductType ='" & ProductID & "') INNER JOIN SPrice ON Products.PID = SPrice.PID ;"

Any help and advice

Thanks & Regards

Ayaz

 
Old June 7th, 2007, 12:20 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You didn't say, but is this in code, or the query?

...(Suppliers INNER JOIN Products ON Suppliers.SID ='" & SupplierID & "' and Products.ProductType ='" & ProductID & "')...

I can't tell if SupplierID and ProductID are supposed to be variables.

In any event, they are probably integers, in which case, if this is cast properly, it would be:

...(Suppliers INNER JOIN Products ON Suppliers.SID =" & SupplierID & " AND Products.ProductType =" & ProductID & ")...

Remove the single quotes since those are only used when the value is not numeric, which I assume it is here.

Given that it is a numeric value, and you are taking it from somewhere, which you don't show since you didn't post the code, it should at least be:

...(Suppliers INNER JOIN Products ON Suppliers.SID =" & Me.SupplierID & " AND Products.ProductType =" & Me.ProductID & ")...

HOWEVER, Access gets freaky when you try to pass values from the form directly into SQL strings at run time, so I am guessing this is the cause of the error. I would do this:

Dim iSuppID, iProdID As Integer
Dim sSQL As String

iSuppID = Me.SupplierID
iProdID = Me.ProductID

sSQL = "SELECT Products.PID, SPrice.PID, Products.SID, Suppliers.[Name], Products.[Description], Products.ProductType, SPrice.MinQuan, SPrice.Currency, SPrice.Price, SPrice.Type, SPrice.SDate FROM (Suppliers INNER JOIN Products ON Suppliers.SID =" & iSuppID & " AND Products.ProductType =" & iProdID & ")INNER JOIN SPrice ON Products.PID = SPrice.PID"

Me.ExportSPriceToExcel_subform.Form.Recordsource = sSQL

The closing semicolon is not necessary.

Did any of that help?

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
hi i got runtime error 13 Type Mismatch error sriharsha345 Access VBA 2 February 21st, 2008 09:30 AM
runtime error dhoward VB.NET 2002/2003 Basics 2 November 1st, 2007 03:30 PM
Runtime Error whiterainbow ASP.NET 2.0 Professional 2 September 12th, 2006 01:20 AM
mysterious error runtime error '451' coyotworks Excel VBA 1 May 12th, 2006 03:57 PM
Runtime Error rwiethorn ASP.NET 1.0 and 1.1 Basics 1 January 27th, 2004 02:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.